UIViewController A、B。
A实现横屏,A转到B。怎么做?取消B的水平屏幕。
B代码:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return NO;
}是不好的!为什么??请帮帮我!谢谢!
发布于 2010-10-25 10:34:10
如果B与A在选项卡栏上,这将不起作用。您需要以模态方式显示B或将其推送到导航控制器上-您还需要在B中至少返回一个方向的YES。
标签栏控制器只支持其所有视图所支持的方向。
发布于 2012-05-10 06:37:17
我刚刚在我的iOS 5.1下的应用程序中修复了这个问题。这是一个古老的问题,但我将把这个问题留给后人,因为我还没有看到其他人在没有应用大量CGAffineTransform代码的情况下解决这个问题,也没有解决真正的问题,那就是UIInterfaceOrientation和UIDeviceOrientation不同步。
在我的例子中,当我从一个只有肖像的ViewController进入一个纵向和横向的ViewController时,我只需要调整方向,而设备在转换之前已经进行了物理旋转。
// The "Interface Orientation" and the "Device Orientation" can become separated in some cases.
// Make sure the view controller only supports the interface orientation for the current device rotation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
int deviceRotation = [[UIDevice currentDevice] orientation];
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
if (deviceRotation == UIDeviceOrientationUnknown ||
deviceRotation == UIDeviceOrientationFaceUp ||
deviceRotation == UIDeviceOrientationFaceDown)
return YES;
if (deviceRotation != interfaceOrientation)
return NO;
else
return YES;
}https://stackoverflow.com/questions/4011433
复制相似问题