zoukankan      html  css  js  c++  java
  • ios一些关于系统功能的判断和设置

    swift判断是真机还是模拟器:

    static let isSimulator: Bool = {

                var isSim = false

                #if arch(i386) || arch(x86_64)

                    isSim = true

                #endif

                return isSim

            }()

     

    // 判断当前手机定位服务是否开启

            if #available(iOS 8.0, *) {

                if CLLocationManager.locationServicesEnabled() && (CLLocationManager.authorizationStatus() == .AuthorizedAlways || CLLocationManager.authorizationStatus() == .NotDetermined){

                    print("手机定位服务开启")

                }else {

                    print("手机定位服务未开启")

                    let title = NSAttributedString(string: "小邦儿童手表需要打开手机定位服务")

                    HUD.showAttrMsg(title, alignment: .Center, titleOK: "设置", blkOK: { (info) in

                        print("跳转")

                        self.turnToSetting()

                        }, titleCancel: "取消", blkCancel: nil)

                    return

                }

            } else {

                // Fallback on earlier versions

                if CLLocationManager.locationServicesEnabled(){

                    print("手机定位服务开启")

                }else {

                    print("手机定位服务未开启")

                    self.turnToSetting()

                    return

                }

            }

    //跳转到设置界面

        func turnToSetting() {

            let url = NSURL(string: "prefs:root=LOCATION_SERVICES")

            UIApplication.sharedApplication().openURL(url!)

        }

      打开系统界面的一些参数

    List of currently known URLs in the Settings app:

    prefs:root=General&path=About  //关于  

    prefs:root=General&path=ACCESSIBILITY//重力感应 

    prefs:root=AIRPLANE_MODE//飞行模式

    prefs:root=General&path=AUTOLOCK//自动锁定

    prefs:root=General&path=USAGE/CELLULAR_USAGE//用量

    prefs:root=Brightness//亮度调节

    prefs:root=General&path=Bluetooth//蓝牙

    prefs:root=General&path=DATE_AND_TIME//时间和日期

    prefs:root=FACETIME//

    prefs:root=General//通用

    prefs:root=General&path=Keyboard//键盘

    prefs:root=CASTLE//

    prefs:root=CASTLE&path=STORAGE_AND_BACKUP//

    prefs:root=General&path=INTERNATIONAL//

    prefs:root=LOCATION_SERVICES//

    prefs:root=ACCOUNT_SETTINGS//

    prefs:root=MUSIC//

    prefs:root=MUSIC&path=EQ//

    prefs:root=MUSIC&path=VolumeLimit//

    prefs:root=General&path=Network//

    prefs:root=NIKE_PLUS_IPOD//

    prefs:root=NOTES//

    prefs:root=NOTIFICATIONS_ID//

    prefs:root=Phone//

    prefs:root=Photos//

    prefs:root=General&path=ManagedConfigurationList//

    prefs:root=General&path=Reset//

    prefs:root=Sounds&path=Ringtone//

    prefs:root=Safari//

    prefs:root=General&path=Assistant//

    prefs:root=Sounds//

    prefs:root=General&path=SOFTWARE_UPDATE_LINK//

    prefs:root=STORE//

    prefs:root=TWITTER//

    prefs:root=General&path=USAGE//

    prefs:root=VIDEO//

    prefs:root=General&path=Network/VPN//

    prefs:root=Wallpaper//

    prefs:root=WIFI//

    prefs:root=INTERNET_TETHERING//

     

    获取设备型号

    static var modelName: String {
            var systemInfo = utsname()
            uname(&systemInfo)
            let machineMirror = Mirror(reflecting: systemInfo.machine)
            let identifier = machineMirror.children.reduce("") { identifier, element in
                guard let value = element.value as? Int8 where value != 0 else { return identifier }
                return identifier + String(UnicodeScalar(UInt8(value)))
            }
            
            switch identifier {
            case "iPod5,1":                                 return "iPod Touch 5"
            case "iPod7,1":                                 return "iPod Touch 6"
            case "iPhone3,1", "iPhone3,2", "iPhone3,3":     return "iPhone 4"
            case "iPhone4,1":                               return "iPhone 4s"
            case "iPhone5,1", "iPhone5,2":                  return "iPhone 5"
            case "iPhone5,3", "iPhone5,4":                  return "iPhone 5c"
            case "iPhone6,1", "iPhone6,2":                  return "iPhone 5s"
            case "iPhone7,2":                               return "iPhone 6"
            case "iPhone7,1":                               return "iPhone 6 Plus"
            case "iPhone8,1":                               return "iPhone 6s"
            case "iPhone8,2":                               return "iPhone 6s Plus"
            case "iPad2,1", "iPad2,2", "iPad2,3", "iPad2,4":return "iPad 2"
            case "iPad3,1", "iPad3,2", "iPad3,3":           return "iPad 3"
            case "iPad3,4", "iPad3,5", "iPad3,6":           return "iPad 4"
            case "iPad4,1", "iPad4,2", "iPad4,3":           return "iPad Air"
            case "iPad5,3", "iPad5,4":                      return "iPad Air 2"
            case "iPad2,5", "iPad2,6", "iPad2,7":           return "iPad Mini"
            case "iPad4,4", "iPad4,5", "iPad4,6":           return "iPad Mini 2"
            case "iPad4,7", "iPad4,8", "iPad4,9":           return "iPad Mini 3"
            case "iPad5,1", "iPad5,2":                      return "iPad Mini 4"
            case "iPad6,7", "iPad6,8":                      return "iPad Pro"
            case "AppleTV5,3":                              return "Apple TV"
            case "i386", "x86_64":                          return "Simulator"
            default:                                        return identifier
            }
        }

  • 相关阅读:
    install kde in ubuntu
    Upgrade to or Install Cinnamon 2.4 in Ubuntu
    enjoy dollar vs cash dollar
    opencv linux
    高频交易都有哪些著名的算法
    wpf
    opencv mat flags含义
    gphoto2 canon eos450d
    gphoto2
    task optimization之superglue分析
  • 原文地址:https://www.cnblogs.com/hazhede/p/5703470.html
Copyright © 2011-2022 走看看