作家
登录

代码处理iOS的横竖屏旋转

作者: 来源: 2017-07-25 13:05:41 阅读 我要评论

  •  
  • #define SCREEN_MAX MAX(SCREEN_HEIGHT,SCREEN_WIDTH)  
  • 解释:竖屏时刻,宽是SCREEN_MIN,高是SCREEN_MAX;横屏时刻,宽是SCREEN_MAX,高是SCREEN_MIN。

    3、屏幕扭转下处理Demo

    1. //监听UIApplicationDidChangeStatusBarOrientationNotification的处理 
    2.  
    3. - (void)handleStatusBarOrientationChange: (NSNotification *)notification{ 
    4.  
    5.   
    6.  
    7.     UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; 
    8.  
    9.     BOOL isLandscape = NO
    10.  
    11.     switch (interfaceOrientation) { 
    12.  
    13.   
    14.  
    15.         case UIInterfaceOrientationUnknown: 
    16.  
    17.             NSLog(@"未知偏向"); 
    18.  
    19.             break; 
    20.  
    21.   
    22.  
    23.         case UIInterfaceOrientationPortrait: 
    24.  
    25.         case UIInterfaceOrientationPortraitUpsideDown: 
    26.  
    27.             isLandscape = NO
    28.  
    29.             break; 
    30.  
    31.   
    32.  
    33.         case UIInterfaceOrientationLandscapeLeft: 
    34.  
    35.         case UIInterfaceOrientationLandscapeRight: 
    36.  
    37.             isLandscape = YES; 
    38.  
    39.             break; 
    40.  
    41.   
    42.  
    43.         default
    44.  
    45.             break; 
    46.  
    47.     } 
    48.  
    49.     if (isLandscape) { 
    50.  
    51.         self.tableView.frame = CGRectMake(0, 0, SCREEN_MAX, SCREEN_MIN - 44); 
    52.  
    53.     }else
    54.  
    55.         self.tableView.frame = CGRectMake(0, 0, SCREEN_MIN, SCREEN_MAX - 64); 
    56.  
    57.     } 
    58.  
    59.   
    60.  
    61.     [self.tableView reloadData]; 

        推荐阅读

        2017,最受欢迎的 15 大 Python 库有哪些?

      近年来,Python 在数据科学行业扮演着越来越重要的角色。是以,我根据比来的应用体验,在本文中列出了对数据科学家、工程师们最有效的那些库。因为这些库都开源了,我们大年夜Github上惹人>>>详细阅读


      本文标题:代码处理iOS的横竖屏旋转

      地址:http://www.17bianji.com/lsqh/36388.html

    关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)