我在TabBarController中有一个带有3个选项卡的应用程序。在第一个选项卡上,当用户按下NavigationBar上的按钮时,可以启用从纵向到横向的旋转?用户第一次无法旋转,只有当他按下按钮时。
我正在使用SDK iOS 6。
提前致谢!
答案 0 :(得分:6)
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return allowedToRotate;
}
然后在您的班级标题中只有一个BOOL allowedToRotate;
,并在您想要允许旋转时将其设置为YES。如果您使用的是iOS 6:
-(NSUInteger)supportedInterfaceOrientations {
if (allowedToRotate)
return UIInterfaceOrientationMaskAll;
else
return UIInterfaceOrientationMaskPortrait;
}
这应该有用,虽然我还没试过......
答案 1 :(得分:2)
这对我起了作用......不确定它是否是最佳方式......但它确实有效:
-(BOOL) shouldAutorotate {
// Return YES for supported orientations
return NO;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
//Setting the orientation of the view. Ive set it to portrait here.
return UIInterfaceOrientationPortrait;
}