我们的应用遭到拒绝,因为该应用不会以上下颠倒的方向旋转。
所以我们有一个标签栏应用,将代码添加到所有标签...
应该是AutorotateToInterfaceOrientation
没有道理,将此代码添加到Appdelegate并没有帮助,我们做错了什么?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
最佳答案
UITabbarcontroller是UIViewcontroller的子类。要解决您的问题,只需为UITabbarcontroller实现子类或添加类别即可:
@interface UITabBarController (rotation)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
@end
@implementation UITabBarController (rotation)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
@end
如果要使标签栏仅旋转成纵向和上下颠倒,请使用以下代码代替
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait ||
interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}