zoukankan      html  css  js  c++  java
  • app基本信息

    1.获取设备信息

        NSLog(@"设备名称:%@",[[UIDevice currentDevice] systemName]);
        NSLog(@"版本号:%@",[[UIDevice currentDevice] systemVersion]);
        NSLog(@"设备名:%@",[[UIDevice currentDevice] name]);
        NSLog(@"设备模式:%@",[[UIDevice currentDevice] model]);
        NSLog(@"本地设备模式:%@",[[UIDevice currentDevice] localizedModel]);
        NSLog(@"唯一标识%@",[[UIDevice currentDevice] identifierForVendor].UUIDString);
        NSLog(@"%d",[[UIDevice currentDevice] orientation]);

          UIDevice提供了多种属性、类函数及状态通知,帮助我们全方位了解设备状况。

          从检测电池电量到定位设备与临近感应,UIDevice所做的工作就是为应用程序提供用户及设备的一些信息。

          UIDevice类还能够收集关于设备的各种具体细节,例如机型及iOS版本等。

          其中大部分属性都对开发工作具有积极的辅助作用。下面的代码简单的使用UIDevice获取手机属性

    2.获取app信息

        NSDictionary *dicInfo = [[NSBundle mainBundle] infoDictionary];
        // CFShow(dicInfo);
        NSString *strAppName = [dicInfo objectForKey:@"CFBundleDisplayName"];
        NSLog(@"App应用名称:%@", strAppName);   // 当前应用名称
        
        NSString *strAppVersion = [dicInfo objectForKey:@"CFBundleShortVersionString"];
        NSLog(@"App应用版本:%@", strAppVersion);    // 当前应用软件版本  比如:1.0.1
      
        NSString *strAppBuild = [dicInfo objectForKey:@"CFBundleVersion"];
        NSLog(@"App应用Build版本:%@", strAppBuild);      // 当前应用版本号码   int类型

          bundle是一个目录,其中包含了程序会使用到的资源. 这些资源包含了如图像,声音,编译好的代码,nib文件(用户也会把bundle称为plug-in). 对应bundle,cocoa提供了类NSBundle.

         一个应用程序看上去和其他文件没有什么区别. 但是实际上它是一个包含了nib文件,编译代码,以及其他资源的目录. 我们把这个目录叫做程序的main bundle。通过这个路径可以获取到应用的信息,例如应用名、版本号等。

    3.本地化信息

        NSLog(@"---%@",NSLocaleIdentifier);
    
        //Getting the User’s Language
        NSArray *languageArray = [NSLocale preferredLanguages];
        NSString *language = [languageArray objectAtIndex:0];
        NSLog(@"语言:%@", language);//en
        
        NSLocale *locale = [NSLocale currentLocale];
        NSString *country = [locale localeIdentifier];
        NSLog(@"国家:%@", country); //en_US

         NSLocale可以获取用户的本地化信息设置,例如货币类型,国家,语言,数字,日期格式的格式化,提供正确的地理位置显示等等。下面的代码获取机器当前语言和国家代码。

  • 相关阅读:
    uniapp 画圆形或多边形雷达图
    uniApp开发之公用配置文件common.js
    FastAdmin 表格排序
    fastadmin SelectPage field显示多个字段
    PHP装饰器模式
    PHP原型模式,(理解:创建并初始化对象,再复制一个对象避免重复初始化)
    PHP设计模式-观察者模式
    为什么 echo 3 . print(2) . print(4) . 5 . 'c'的结果是45c2131
    PHP数组式访问接口ArrayAccess用法分析
    浏览器兼容性问题总结
  • 原文地址:https://www.cnblogs.com/gulong/p/4716035.html
Copyright © 2011-2022 走看看