Auto Rotate Tab Bar application
Hey guys,
I am trying to auto rotate my Tab Bar application. Apparently, I know most people will say to this problem is return YES;
or that all t开发者_开发百科he Tab Bar Items have to be in the same class in order to auto rotate. No. It didn't work for me. So first of all, I have 4 Tab Bar Items, each with it's own Classes. My first 2 Tab Bar Items have UIWebViews, second is a Table View and last is an Image View with buttons. Now I practiced implementing the auto rotate code for my first Tab Bar Item, which is a UIWebView using this code since return YES;
didn't work for me:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait);
if (interfaceOrientation == UIInterfaceOrientationPortrait ||
interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight)
return YES;
else
return NO;
}
Using this code without a Tab Bar worked for me, but when using this with a Tab Bar application, it didn't work for me. Also when programmers said to me to have all other Tab Bar applications have to have the same Class file, I can't do that because each of my Tab Bars have their own Class file, as I've said before.
So hopefully, someone can help me with this situation in order to auto rotate the entire Tab Bar, thanks
You need to return YES
on all view controllers in the tabbar.
Also your code can be shorter, just this:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
you are aware that you return YES (in case of portrait orientation) or NO from this method in the first line?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait);
// this never gets called:
// if (interfaceOrientation == UIInterfaceOrientationPortrait ||
// interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
// interfaceOrientation == UIInterfaceOrientationLandscapeRight)
// return YES;
// else
// return NO;
}
精彩评论