[英]How to rotate from portrait to landscape?
How to rotate from portrait to landscape? 如何从纵向旋转到横向? What would I have to implement? 我要实施什么? And what must I do that my views resize to the new width? 我该怎么办才能将视图调整为新的宽度?
The below method "return yes" will make orientation change if it is "return NO" the orientation will not change. 下面的方法“ return yes”将改变方向,如果它是“ return NO”,则不会改变方向。
- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) orientation
{
return YES;
}
All the best. 祝一切顺利。
To answer the second part of your question, you can add logic to resize or position views by overriding the -willRotateToInterfaceOrientation:duration:
method, eg: 要回答问题的第二部分,您可以通过覆盖-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
}
}
if your view controller is not the top-layer view controller, you must pass the message willRotateToInterfaceOrientation:duration: from the top-layer view controller.. your view controller might not receive the message... 如果您的视图控制器不是顶层视图控制器,则必须从顶层视图控制器传递消息willRotateToInterfaceOrientation:duration:。您的视图控制器可能不会收到此消息...
at my top-layer view controller's willRotateToInterfaceOrientation:duration:, i included this line... (frameViewController is my 2nd level view controller) 在我的顶层视图控制器的willRotateToInterfaceOrientation:duration:处,我包括了这一行...(frameViewController是我的第二层视图控制器)
if (frameViewController)
[frameViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.