我有一个在TabBarController中有3个选项卡的应用程序。在第一个选项卡上,当用户在NavigationBar上按下按钮时,可以从纵向旋转到横向?用户第一次无法旋转,只有当他按下按钮时才能旋转。如何启用/禁用方向(旋转),直到按UIBarButtonItem?
我使用SDK iOS 6.
在此先感谢!
我有一个在TabBarController中有3个选项卡的应用程序。在第一个选项卡上,当用户在NavigationBar上按下按钮时,可以从纵向旋转到横向?用户第一次无法旋转,只有当他按下按钮时才能旋转。如何启用/禁用方向(旋转),直到按UIBarButtonItem?
我使用SDK iOS 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;
}
这应该工作,虽然我还没有尝试过...
这奏效了,我......不知道,如果它的最好方式.. ..但它的工作原理:
-(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;
}
这也适用于我。 thnx :) – deltaaruna
你只是把这些方法覆盖在CustomControllerView.m文件中?不适合我... –
谁的轮转ru在说什么? –
@太子对不起,从肖像到风景。 –