I'm new to stackoverflow and to objective-C programming. I have searched for the issue described below, but I'm not able to find a working solution.
My application is a simple offline browsing app, with navigation structure. In the appDelegate I load the RootViewController (UITableViewController) in one of the following ways:
Solution A
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
return YES;
Solution B
RootViewController* rootviewcontroller = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
navigationController = [[UINavigationController alloc] initWithRootViewController:rootviewcontroller];
The rootViewController simply push some views, ie
TipAndTrickViewController *mTipAndTrick = [[TipAndTrickViewController alloc]initWithNibName:@"TipAndTrickViewController" bundle:nil];
[self.navigationController pushViewController:mTipAndTrick animated:YES];
In the deeper view I present a detail modalView (UIViewController). What I want is to enable autorotate only in this last view. The portait orientation is the desired for all the previoues wiews. The last view implements in the right way:
shouldAutorotateToInterfaceOrientation:interfaceOrientation
shouldAutorotate
willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration
willAnimateRotationToInterfaceOrientation:interfaceOrientation duration:duration
Overriding
shouldAutorotate
shouldAutorotateToInterfaceOrientation:interfaceOrientation
making them returning NO/YES in the rootViewController and setting the allowed orientation in the desired way, using
supportedInterfaceOrientations
(both in rootViewCOntroller and in the last view), I get those results:
What I'm doing in the wrong way? Thank you in advance for your help
Add these to your viewController and let me know if it works or not .
// iOS5 Rotation
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
// iOS6 Rotation
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
- (BOOL)shouldAutorotate
{
return YES;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.