码迷,mamicode.com
首页 > 移动开发 > 详细

iOS开发——检测屏幕旋转

时间:2015-04-26 16:39:42      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

步骤一、注册通知

   1:  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarOrientationChange:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];

 

步骤二、判断方向

 

   1:  - (void)statusBarOrientationChange:(NSNotification *)notification
   2:   
   3:  {
   4:   
   5:  UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
   6:   
   7:  if (orientation == UIInterfaceOrientationLandscapeRight) // home键靠右
   8:   
   9:  {
  10:   
  11:  //
  12:   
  13:  }
  14:   
  15:  if (
  16:   
  17:  orientation ==UIInterfaceOrientationLandscapeLeft) // home键靠左
  18:   
  19:  {
  20:   
  21:  //
  22:   
  23:  }
  24:   
  25:  if (orientation == UIInterfaceOrientationPortrait)
  26:   
  27:  {
  28:   
  29:  //
  30:   
  31:  }
  32:   

参考来源:http://www.2cto.com/kf/201410/345818.html

iOS开发——检测屏幕旋转

标签:

原文地址:http://www.cnblogs.com/zeyang/p/4457913.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!