简体   繁体   English

如何从纵向旋转到横向?

[英]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.

相关问题 如何将视图从纵向模式旋转到横向模式 - How to rotate view from portrait to landscape mode 如何将视频人像旋转到风景 - How to rotate video portrait to landscape 如何在iOS 6及更高版本中将单个视图从纵向旋转为横向? - How to rotate a single view from portrait to landscape in iOS 6 and above? 加载视图后如何从横向旋转到纵向? - How do I rotate from landscape to portrait upon loading a view? 从纵向旋转到横向时如何更改UIBarButtonItem的大小? - how to change the UIBarButtonItem size when rotate from the portrait to landscape? Monotouch在纵向/横向中旋转视图 - Monotouch rotate view in Portrait/Landscape iPhone 上的响应式网站 - 从横向旋转到纵向时不需要的空白 - Responsive website on iPhone - unwanted white space on rotate from landscape to portrait 应用程序可以自动从iPad上的肖像旋转到风景,但不能在iPhone上 - App can auto rotate to landscape from portrait on iPad but not on iPhone 即使在 iPad 中屏幕旋转为横向,如何锁定纵向视图 - How to lock the portrait view even if screen rotate to landscape in ipad 如何“旋转图像,仅当它处于纵向模式时(但不是在landScape模式下)” - How it is possible to 'rotate image, only if it is in portrait mode (But not in landScape mode)'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM