In my view controller, I implement two methods for controlling interface orientation:
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutorotate
{
return YES;
}
In the supportedInterfaceOrientations
method, I return UIInterfaceOrientationMaskPortrait
but at that time I realized that the shouldAutorotate
method is not being called.
But I change to return UIInterfaceOrientationPortrait
in the supportedInterfaceOrientations
method. The shouldAutorotate
method is being called, but there is an error that mentions in following:
UIApplicationInvalidInterfaceOrientation
, reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'
By the way, I select all orientations in the supported interface orientations.
EDITED
i use viewController and embed with navigationController. here is AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate,UINavigationControllerDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@property (readonly, strong, nonatomic) UINavigationController *navController;
- (void)saveContext;
- (NSURL *)applicationDocumentsDirectory;
@end
in didFinishLaunchingWithOptions method under AppDelegate.m
navController = (UINavigationController *)self.window.rootViewController;
IPad_HomeViewController *rootVC=(IPad_HomeViewController *)navController.topViewController;
rootVC.managedObjectContext = self.managedObjectContext;
return YES;
in my IPad_HomeViewController,
@interface IPad_HomeViewController : UIViewController <UINavigationControllerDelegate>
@property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@end