资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

ios开发横屏,iOS开发 强制pad横屏

iOS横竖屏要点与横屏返回问题

主要下面三个方法

创新互联公司专注为客户提供全方位的互联网综合服务,包含不限于成都做网站、网站设计、徽州网络推广、小程序制作、徽州网络营销、徽州企业策划、徽州品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联公司为所有大学生创业者提供徽州建站搭建服务,24小时服务热线:13518219792,官方网址:www.cdcxhl.com

1、当前viewController是window的rootViewController.

2、当前viewController是modal模式的. 即, 此viewController是被调用

presentModalViewController 而显示出来的.

对于非modal模式的viewController:如果不是rootViewController,则重写 supportedInterfaceOrientations , preferredInterfaceOrientationForPresentation 以及 shouldAutorotate 方法, 按照当前viewController的需要返回响应的值.如果是rootViewController,则如下重写方法:

这样就绕开了UIKit只调用rootViewController的方法的规则. 把决定权交给了当前正在显示的viewController.

对于modal

模式的viewController. 则按照需要重写supportedInterfaceOrientations,

preferredInterfaceOrientationForPresentation

以及shouldAutorotate 方法即可.

TIPS:

[UIViewController attemptRotationToDeviceOrientation]; 可以重新调用以上的方法。

虽然A界面不支持横屏,但是如果下个B界面支持横屏,B在横屏模式返回的话,A也变横屏了。这里有个简单的设值方法

A界面也重写方法即可

重写

有时候想自己控制横竖屏 ,比如视图播放界面。

setOrientation 在iOS3以后变为私有方法了,不能直接去调用此方法,否则后果就是被打回。

不能直接调用,但是可以间接的去调用,下面的方法就是利用 KVO机制去间接调用.

iOS 自定义UIWindow 横屏时适配问题

当自定义一个UIWindow,并在window添加控件,横屏时,window并没有跟随视图旋转。

解决方法1:(苹果推荐这样使用)

1.定义一个UIViewController,并设置为当前Window的rootViewController,将控件添加到自定义的UIViewController上,调用时使用self.mineWindow.mineRootViewController.button...

2.在自定义的UIViewController中添加横屏方法:

- (BOOL)shouldAutorotate {

returnYES;

}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {

return UIInterfaceOrientationMaskLandscape;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {

return UIInterfaceOrientationLandscapeRight;

}

解决方法2:

对UIWindow进行旋转(UIWindow继承自UIView):

UIInterfaceOrientation orientation = [[UIApplication sharedApplication]statusBarOrientation];

if (orientation == UIInterfaceOrientationLandscapeLeft) {

CGAffineTransform rotation = CGAffineTransformMakeRotation(3*M_PI/2);

[self setTransform:rotation];

}

if (orientation == UIInterfaceOrientationLandscapeRight) {

CGAffineTransform rotation = CGAffineTransformMakeRotation(M_PI/2);

[self setTransform:rotation];

}

如有不当之处请@我。

iOS开发 横竖屏切换问题

在你想支持横竖屏的viewController里面重写两个方法:

1

2

3

4

5

6

7

8

9

10

11

// 支持设备自动旋转

- (BOOL)shouldAutorotate

{

return YES;

}

// 支持横竖屏显示

- (NSUInteger)supportedInterfaceOrientations

{

return UIInterfaceOrientationMaskAll;

}

这样在这个viewController中就可以横竖屏切换了。

注意如果你window的rootViewController是一个navigationController,可能会出现以下问题:

你的navigationController只支持竖屏,但是你push到了某个新的controller中,这个controller支持横竖屏,当你在新的controller中切换到横屏后(也有可能在切换到横屏然后pop回来后),这时候程序会闪退,因为你的navigationController不支持横屏。

如果你想解决这个问题,就需要自己写一个UINavigationController的子类,在这个类中重写方法:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

- (BOOL)shouldAutorotate

{

return [self.viewControllers.lastObject shouldAutorotate];

}

- (NSUInteger)supportedInterfaceOrientations

{

return [self.viewControllers.lastObject supportedInterfaceOrientations];

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

{

return [self.viewControllers.lastObject preferredInterfaceOrientationForPresentation];

}

然后用这个类去创建实例作为window的rootViewController,这样就可以避免这个问题了。

ios开发iphone6横屏启动图怎么设置

1、iPhone6 Plus共有两种显示模式,分别为标准和放大模式官网 留言只有在“标准模式”下,才支持横屏。所以要确保显示模式在标准模式状态下。

2、在控制中心将“方向锁定”关闭即可让iPhone Plus在手机横放时自动变成横屏显示。

iPhone6 Plus显示模式更改方法

激活苹果6手机时,会让你选择显示模式,如果要更改就看下面的步骤。

1、点击主屏上的“设置”

2、在设置选项列表中找到“显示与亮度”。

3、点击“显示模式”

4、选择“放大”或者“标准”模式

5、切换不同的显示模式之后需要重启苹果手机才能生效


网页题目:ios开发横屏,iOS开发 强制pad横屏
URL地址:http://cdkjz.cn/article/dscgogi.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220