zoukankan      html  css  js  c++  java
  • 手机朝向监测

    //添加监测

    - (void)addNotification {
        [//返回一个UIDevice实例;
         [UIDevice currentDevice]beginGeneratingDeviceOrientationNotifications];//改变朝向则获悉这一点;
        
        [[NSNotificationCenter defaultCenter] addObserver:self  selector:@selector(orientationChanged:)   name:@"UIDeviceOrientationDidChangeNotification"
         object:nil];
    }


    //实现方法orientationChanged;
    -(void)orientationChanged:(NSNotification*)notification
    {UIDeviceOrientation orientation=[[UIDevice currentDevice]orientation];


        switch (orientation) {


            case UIDeviceOrientationFaceUp:
                self.orientationLabel.text=@"Face Up!";
                break;


            case UIDeviceOrientationFaceDown:
                self.orientationLabel.text=@"Face Down!";
                break;

            case UIDeviceOrientationPortrait:
                self.orientationLabel.text=@"Standing Up!";
                break;


            case UIDeviceOrientationLandscapeLeft:
                self.orientationLabel.text=@"Left Side!";
                break;


           case UIDeviceOrientationLandscapeRight:
                self.orientationLabel.text=@"Right Side!";
                break;
          
            default:
                self.orientationLabel.text=@"Unknown!";
                break;
        }

    }


    初探佳境,多多学习交流
  • 相关阅读:
    .NET创建WebService服务简单的例子
    SVN服务器搭建
    Visual Studio 2017 系统发布部署服务器教程
    C#进阶--WebApi异常处理机制
    利用iis虚拟目录实现文件服务器功能(分布式存储)
    jQuery 选择器
    jQuery 简介
    从「闭包」到 思考人生
    跨域
    ajax 和 mock 数据
  • 原文地址:https://www.cnblogs.com/sunjianfei/p/5509385.html
Copyright © 2011-2022 走看看