zoukankan      html  css  js  c++  java
  • iPhone设备相关

    获取手机当前版本号

         //获取硬件信息
        UIDevice *device=[UIDevice currentDevice];
        //输出版本号
        NSLog(@"%@",device.systemVersion);

    获取手机方向

    1 通知

     //检测设备朝向使用UIDevice,beginGeneratingDeviceOrientationNotifications方法向通知中心发送朝向信息
        [[UIDevice currentDevice]beginGeneratingDeviceOrientationNotifications];
        // 添加通知
        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];

    2 实现方法

    -(void)orientationChanged:(NSNotification *)notification
    {
        UIDeviceOrientation orientation=[[UIDevice currentDevice]orientation];
        switch (orientation) {
            case UIDeviceOrientationFaceUp:
                NSLog(@"设备正面朝上");
                break;
                case UIDeviceOrientationFaceDown:
                NSLog(@"设备正面朝下");
                break;
                case UIDeviceOrientationPortrait:
                NSLog(@"设备处于正常朝向,主屏幕按钮在下方");
                break;
                case UIDeviceOrientationPortraitUpsideDown:
                NSLog(@"设备处于纵向,主屏幕按钮在上方");
                break;
                case UIDeviceOrientationLandscapeLeft:
                NSLog(@"设备侧立,左边朝下");
                break;
                case UIDeviceOrientationLandscapeRight:
                NSLog(@"设备侧立,右边朝下");
                break;
            default:
                break;
        }

    手机震动,提示音,提醒

    1 首先导入框架:AudioToolbox ,在文件中导入该框架的借口文件:#import<AudioToolbox/AudioToolbox.h>

    音效

    - (IBAction)buttonClick:(UIButton *)sender {
    
        //声明变量soundid,用来引入音效文件
        SystemSoundID soundid;
        //得到声音文件路径
        NSString *soundfile=[[NSBundle mainBundle]pathForResource:@"soundeffect" ofType:@"wav"];
    
        //1.桥接指向文件位置 __bridge.将C语言结构转化为OC语言对象
        AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:soundfile], &soundid);
        //播放警告音
        AudioServicesPlaySystemSound(soundid);
    }

    提示音

    - (IBAction)alertButtonClick:(UIButton *)sender {
        SystemSoundID soundid;
        NSString *soundfile=[[NSBundle mainBundle]pathForResource:@"soundeffect" ofType:@"wav"];
        AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:soundfile], &soundid);
        //警告音,当用户调整为静音时震动
        AudioServicesPlayAlertSound(soundid);
    }



    震动
    - (IBAction)shakeButtonClick:(UIButton *)sender {
        SystemSoundID soundid;
        //不论手机状态,只有震动
        AudioServicesPlaySystemSound(soundid);
    }
  • 相关阅读:
    H5本地存储技术和微信小程序中的本地存储
    CVE-2019-0708漏洞利用
    微信小程序入门到实战(1)-基础知识
    Nuxt.js打造旅游网站第3篇_登录页面的编写
    Nuxt.js打造旅游网站第2篇_首页开发
    vuex之仓库数据的设置与获取
    axios细节之绑定到原型和axios的defaults的配置属性
    Nuxt.js打造旅游网站第1篇_项目环境搭建
    mongdb数据中文文档
    关于通过linux访问windows执行windows环境下的Python文件的相关操作。
  • 原文地址:https://www.cnblogs.com/cdp-snail/p/4913791.html
Copyright © 2011-2022 走看看