For two days I am working on iOS app to fix the rotation issue, but no success. I have search everywhere in internet to find any solution, but couldn't find anything which fix my app rotation.
I have added all new function that introduced in iOS 6 for rotation to my AppDelegate class.
This is my code in AppDelegate.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
HomeViewController *controller;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
controller = [[HomeViewController alloc] initWithNibName: @"iPadHomePage" bundle: nil];
}
else {
controller = [[HomeViewController alloc] initWithNibName: @"HomePage" bundle: nil];
}
NSMutableArray *controllers = [[NSMutableArray alloc] init];
[controllers addObject:controller];
navController.viewControllers = controllers;
return YES;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
When I google I found out that I shouldn't use [self.window addSubview:tabBarController.view]
as this will not work with iOS 6, so I replace it with [self.window setRootViewController:tabBarController]
in AppDelegate class, but then I am getting an error in main class.
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key labelName
What am I missing?