我正在开发一个应用程序,其中一个 UIViewController 中有许多 UIView。现在的问题是,所有 UIView 都处于横向模式,这里只有一个 UIView 处于纵向模式。我无法使用 shouldAutorotate 方法获得此特定输出。
任何人都可以建议我具体的方法来解决这个问题。
最佳答案
@pratik-bhiyani 谢谢... 但我已经完成了这种代码,以在需要旋转 View 时获取特定代码
- (IBAction)btnClickToRedeem:(id)sender
{
isPortraitRqurd = TRUE;
[self shouldAutorotate];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
if(isPortraitRqurd)
return (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
else
return (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight || toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
if(isPortraitRqurd)
return UIInterfaceOrientationMaskPortrait;
else
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
if(isPortraitRqurd)
{
return UIInterfaceOrientationPortrait;
isPortraitRqurd = FALSE;
}
else
return UIInterfaceOrientationLandscapeRight;
}
关于iphone - ios 6.0 及更高版本中的方向问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16271573/