iOS 6.0之后支持一个页面横屏的方法


拿两个页面举例子:

0、开启旋转:

1、第一个界面实现以下方法

/**
 *  默认显示的方向,preferredInterfaceOrientationForPresentation必须返回一个支持的接口方向
 */
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}
/**
 *  可旋转的方向
 */
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

2、在第二个界面加入以下代码

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeRight;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

------------------------------------------------------------------

因为旋转打开了,所以我们不能在每个界面都去设置只允许竖屏的代码,所以写一个父类在父类里实现竖屏的代码,然后所有的类都继承于这个类就可以了。

优质内容筛选与推荐>>
1、C# 鼠标移动Winform窗体内或者panel容器内的控件 显示虚线/实现虚线框来确定位置
2、SQL存储过程在.NET数据库中的应用
3、JPA 不在 persistence.xml 文件中配置每个Entity实体类的2种解决办法
4、[面试] 2014-5-5
5、Ruby on Rails


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号





    联系我们

    欢迎来到TinyMind。

    关于TinyMind的内容或商务合作、网站建议,举报不良信息等均可联系我们。

    TinyMind客服邮箱:support@tinymind.net.cn