题
如何从肖像到风景旋转?我必须实施什么?我必须做什么,我的观点将其调整到新宽度?
解决方案
下面的方法“返回是”将使方向更改,如果它是“返回”否将不会更改。
- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) orientation
{
return YES;
}
祝一切顺利。
其他提示
要回答问题的第二部分,您可以添加逻辑来调整大小或定位视图 -willRotateToInterfaceOrientation:duration:
方法,例如:
- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (toInterfaceOrientation == UIDeviceOrientationUnknown || toInterfaceOrientation == UIDeviceOrientationFaceUp || toInterfaceOrientation == UIDeviceOrientationFaceDown) {
// do something here for these orientations
}
else {
// do something else for the remaining orientation types
}
}
如果您的视图控制器不是顶层视图控制器,则必须传递消息 WillrotateToInterfaceorientation:持续时间: 从顶层视图控制器中。您的视图控制器可能无法接收消息...
在我的顶层视图控制器的WillrotateToInterfaceorientation:持续时间:我包括此行...(FrameViewController是我的第二级视图控制器)
if (frameViewController)
[frameViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
不隶属于 StackOverflow