iPhone navigation bar rotation issue when coming back from background
Ok, so after weeks of headache, I've given up and decided to turn to expert resource online!
Basically, I am trying to get my iphone application to view in a forced landscape mode (to be precise, for a graph) for just 1 view controller in otherwise a portrait-orientation dominated navigation-bar application.
I got everything working the way it should, EXCEPT when I put the application into background and return, the application returns with the navigation bar moved to where it usually sits in Portrait orientation mode but rotated 90', whilst every others like status bar, the main view are all still i开发者_Go百科n landscape mode.
I've tried to manually correct the navigation bar orientation afterwards, but cocoa seems to ignore this bit of code. It's almost as if the self.view.transform doesn't work when the application returns from background mode. Any suggestions?
LandscapeViewController.m
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return NO;
}
-(void)viewWillAppear:(BOOL)animated {
self.view.transform = CGAffineTransformMakeRotation((M_PI * (90) / 180.0));
self.view.bounds = CGRectMake(0.0, 0.0, 480, 320);
}
This image shows you can see what I mean
http://i.stack.imgur.com/Qx1Si.pngHave you tried this?
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
You should not always return NO from shouldAutorotateToInterfaceOrientation: but return YES for the orientation you support. The iOS then handles the rest.
精彩评论