zoukankan      html  css  js  c++  java
  • app锁定屏幕方向,某一个界面支持屏幕旋转~

    AppDelegate.h 加

    @property (nonatomic, assign) BOOL allowRotation;
    

    Appdelegate.m加

    -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
    {
      if (self.allowRotation) {
        return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
      }
      return UIInterfaceOrientationMaskPortrait;
    }
    - (NSUInteger)supportedInterfaceOrientations
    {
      return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
    }
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
      return UIInterfaceOrientationPortrait;
    }
    

    之后在需要支持屏幕旋转的界面的特定位置上添加代码:

    • 打开屏幕旋转:
      AppDelegate  *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
      delegate.allowRotation = YES;
    
    • 关闭屏幕旋转:
      AppDelegate  *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
      delegate.allowRotation = NO;
    
  • 相关阅读:
    04_Javascript初步第二天(上)
    用python实现省市县多级嵌套下拉列表
    爬虫之 BeautifulSoup与Xpath
    爬虫之 selenium模块
    爬虫请求库 requests
    抽屉网自动点赞 评论
    爬取京东商品信息
    爬取豆瓣电影top250
    爬虫基本原理
    Django auth认证
  • 原文地址:https://www.cnblogs.com/jyking/p/6737277.html
Copyright © 2011-2022 走看看