博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Navi PushVC及Present VC的屏幕旋转
阅读量:4115 次
发布时间:2019-05-25

本文共 1528 字,大约阅读时间需要 5 分钟。

1. 如果没有在Navi中, 则使用下面三个方法来决定屏幕的旋转方向。 同样, 对针present出来的VC也用下面的方法来决定

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {

    returnUIInterfaceOrientationPortrait;

}

- (BOOL)shouldAutorotate {

    return NO;

}

- (NSUInteger)supportedInterfaceOrientation {

    returnUIInterfaceOrientationMaskPortrait;

}

2. 如果在Navi中, 则默认Navi下的VC无法控制自己的屏幕旋转, 应该是因为Navi的push动画的原因吧。 

3. 如果在Navi中, 又想Navi下的VC自己去控制自己的屏幕旋转, 可以在Navi中如下实现,然后在自己的VC中分别控制屏幕的旋转, 实现后发现还是有些问题。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

    return [self.topViewControllershouldAutorotate];

}

-(NSUInteger)supportedInterfaceOrientations

{

    return [self.topViewControllersupportedInterfaceOrientations];

}

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

{

    returnUIInterfaceOrientationPortrait;

}

4. 建议还是在Navi中来限制屏幕的旋转, 然后控制特别需要旋转的界面的弹出方式为present

5. 对于某些界面,以present出来的界面为例, 如果需要针对某些条件来设置屏幕朝向, 可以如下代码:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

    if (self.forVedioPlayer == YES) {

        return YES;

    }else {

        return NO;

    }

}

-(NSUInteger)supportedInterfaceOrientations

{

    if (self.forVedioPlayer == YES) {

        return UIInterfaceOrientationMaskLandscape;

    }else {

        return UIInterfaceOrientationMaskPortrait;

    }

}

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

{

    if (self.forVedioPlayer == YES) {

        return UIInterfaceOrientationLandscapeLeft;

    }else {

        return UIInterfaceOrientationPortrait;

    }

}

下面这篇文章讲得较好,http://blog.sina.com.cn/s/blog_76264a170101e5lb.html

转载地址:http://txwpi.baihongyu.com/

你可能感兴趣的文章
TCP/IP协议三次握手与四次握手流程解析
查看>>
PHP 扩展开发 : 编写一个hello world !
查看>>
inet_ntoa、 inet_aton、inet_addr
查看>>
用模板写单链表
查看>>
链表各类操作详解
查看>>
C++实现 简单 单链表
查看>>
Linux的SOCKET编程 简单演示
查看>>
Linux并发服务器编程之多线程并发服务器
查看>>
C语言内存检测
查看>>
Linux epoll模型
查看>>
Linux系统编程——线程池
查看>>
Linux C++线程池实例
查看>>
shared_ptr的一些尴尬
查看>>
C++总结8——shared_ptr和weak_ptr智能指针
查看>>
c++写时拷贝1
查看>>
Linux网络编程---I/O复用模型之poll
查看>>
Java NIO详解
查看>>
在JS中 onclick="save();return false;"return false是
查看>>
idea 有时提示找不到类或者符号
查看>>
matplotlib.pyplot.plot()参数详解
查看>>