首页 > 移动平台 > 详细

iOS横屏设置的几种方式

时间:2017-03-01 10:52:25      阅读:318      评论:0      收藏:0      [点我收藏+]

1.界面旋转,MainScreen的宽高不变,键盘位置不变

CGFloat duration = [UIApplication sharedApplication].statusBarOrientationAnimationDuration;

[UIView beginAnimations:nil context:nil];

[UIView setAnimationDuration:duration];

self.view.transform =CGAffineTransformMakeRotation(M_PI/2);

[UIView commitAnimations];

 2.界面旋转,MainScreen的宽高改变,键盘位置不变

if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {

        SEL selector = NSSelectorFromString(@"setOrientation:");

        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];

        [invocation setSelector:selector];

        [invocation setTarget:[UIDevice currentDevice]];

        int val = UIInterfaceOrientationLandscapeRight;

        [invocation setArgument:&val atIndex:2];

        [invocation invoke];
}

3.界面旋转,MainScreen的宽高改变,键盘位置改变

a.General—>中勾选Lnadscape Left/Lnadscape Right

技术分享

b.控制器中实现以下两个方法:

// 支持设备自动旋转
- (BOOL)shouldAutorotate
{
    return YES;
}

/**
 *  设置特殊的界面支持的方向,这里特殊界面只支持Home在右侧的情况
 */
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeRight;
}

 

iOS横屏设置的几种方式

原文:http://www.cnblogs.com/liuluoxing/p/6482983.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!