app显示版本号 ios
2016-06-13 20:40:39 cos_sin_tan 阅读数 1620

func versionCheck(){

        let infoDictionary = NSBundle.mainBundle().infoDictionary

        let appDisplayName: AnyObject? = infoDictionary!["CFBundleDisplayName"]

        let majorVersion : AnyObject? = infoDictionary! ["CFBundleShortVersionString"]

        let minorVersion : AnyObject? = infoDictionary! ["CFBundleVersion"]

        let appversion = majorVersion as String

        let iosversion : NSString = UIDevice.currentDevice().systemVersion   //ios 版本

        let identifierNumber = UIDevice.currentDevice().identifierForVendor   //设备 udid

        let systemName = UIDevice.currentDevice().systemName   //设备名称

        let model = UIDevice.currentDevice().model   //设备型号

        let localizedModel = UIDevice.currentDevice().localizedModel   //设备区域化型号  A1533

 

        

        println(appversion)

    }





majorVersion 主程序版本号

minorVersion build 版本号
复制代码
2013-02-06 23:04:00 weixin_33884611 阅读数 3

[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]

返回一个NSString。

转载于:https://my.oschina.net/anyson/blog/108274

2015-12-12 10:27:31 qq_27074387 阅读数 1257

 

 // - app 的 Bundle versions string, short

[[NSBundlemainBundle]objectForInfoDictionaryKey:@"CFBundleShortVersionString"]]

 

 

 

 // - app 的 build

 NSString *key =@"CFBundleVersion";

 NSString *currentVersion = [NSBundlemainBundle].infoDictionary[key];

 

 

 

App默认是有开启了多任务功能,而多任务功能是需要App支持所有方向,如果我们App是有需要支持多任务,则需要开启App对各个方向(上、下、左、右)的支持;如果App不需要开启多任务,则只需要将如下示意图的 requires full screen 勾选

Hidden starus bar  用来启动app的时候隐藏状态栏!

 

 

NSLog(@"%@", [NSBundle mainBundle].infoDictionary);

打印结果如下 :

        2016-07-05 18:08:17.757 DYCode[9224:216214] {
    BuildMachineOSBuild = 15E65;
    CFBundleDevelopmentRegion = en;
    CFBundleExecutable = DYCode;
    CFBundleIdentifier = "com.QG.DYCode";
    CFBundleInfoDictionaryVersion = "6.0";
    CFBundleInfoPlistURL = "Info.plist -- file:///Users/lichaoqun/Library/Developer/CoreSimulator/Devices/0DDD96CE-6C7F-4730-8B8A-F7D20BAAE87D/data/Containers/Bundle/Application/EDC6CF98-434C-4820-89E6-8B921F5289B5/DYCode.app/";
    CFBundleName = DYCode;
    CFBundleNumericVersion = 16809984;
    CFBundlePackageType = APPL;
    CFBundleShortVersionString = "1.0";
    CFBundleSignature = "????";
    CFBundleSupportedPlatforms =     (
        iPhoneSimulator
    );
    CFBundleVersion = 1;
    DTCompiler = "com.apple.compilers.llvm.clang.1_0";
    DTPlatformBuild = "";
    DTPlatformName = iphonesimulator;
    DTPlatformVersion = "9.3";
    DTSDKBuild = 13E230;
    DTSDKName = "iphonesimulator9.3";
    DTXcode = 0731;
    DTXcodeBuild = 7D1014;
    LSRequiresIPhoneOS = 1;
    MinimumOSVersion = "8.2";
    NSAppTransportSecurity =     {
        NSAllowsArbitraryLoads = 1;
    };
    UIDeviceFamily =     (
        1,
        2
    );
    UILaunchStoryboardName = LaunchScreen;
    UIMainStoryboardFile = Main;
    UIRequiredDeviceCapabilities =     (
        armv7
    );
    UISupportedInterfaceOrientations =     (
        UIInterfaceOrientationPortrait,
        UIInterfaceOrientationLandscapeLeft,
        UIInterfaceOrientationLandscapeRight
    );
}

2014-02-24 11:11:51 chaoyuan899 阅读数 22536

看代码的时候看到一句,用于获取.plist文件的版本号

labelVersion.text = [NSString stringWithFormat:@"v%@", [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey]];



比较感兴趣的是后面的参数 kcFBundleVersionKey ,竟然是CFBundle.h已经定于好的属性,下面有这个属性的注释

const CFStringRef kCFBundleVersionKey;

    /* The version number of the bundle.  For Mac OS 9 style version numbers (for example "2.5.3d5"), */

    /* clients can use CFBundleGetVersionNumber() instead of accessing this key directly since that */

    /* function will properly convert the version string into its compact integer representation. */

还有好多是kcFXXX开头的Standard Info.plist keys 属性,有兴趣可以自己看一下CFBundle.h,研究一下它们的用法,


2016-01-28 17:03:10 yy1992320 阅读数 132
  1. NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];  
  2. NSString *name = [infoDictionary objectForKey:@"CFBundleDisplayName"];  
  3. NSString *version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];  
  4. NSString *build = [infoDictionary objectForKey:@"CFBundleVersion"];  
  5. NSString *label = [NSString stringWithFormat:@"%@ v%@ (build %@)", name, version, build];  
  6.   
  7. NSLog(@"%@",label)

iOS 设置App版本号

阅读数 713

ios设置App版本号

阅读数 597

ios获取app版本号

阅读数 809

ios设置App版本号

阅读数 2361

没有更多推荐了,返回首页