iOS判断手机方向改变

下面是来客网 jb51.cc 通过网络收集整理的代码片段。

来客网小编现在分享给大家,也给大家做个参考。

//监听手机方向改变事件

[[NSNotificationCenter defaultCenter] addObserver:self

     selector:@selector(orientationChanged)

     name:UIDeviceOrientationDidChangeNotification

      object:nil];

//处理函数

-(void) orientationChanged

{

   switch ([[UIDevice currentDevice]orientation]) {

      case  UIDeviceOrientationPortrait:

         NSLog(@"portrait");

      break;

      case  UIDeviceOrientationPortraitUpsideDown:

         NSLog(@"portraitUpSideDown");

         break;

      case  UIDeviceOrientationLandscapeLeft:

         NSLog(@"landscapeLeft");

         break;

      case  UIDeviceOrientationLandscapeRight:

         NSLog(@"landscapeRight");

         break;

      case  UIDeviceOrientationFaceDown:

         NSLog(@"facedown!!");

         break;

      case  UIDeviceOrientationFaceUp:

          NSLog(@"FaceUp");

          break;

      default:

          break;

    }

}

以上是来客网(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。

以上是来客网为你收集整理的iOS判断手机方向改变全部内容,希望文章能够帮你解决iOS判断手机方向改变所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。