Version of iOS program implementation new feature display function

Source: Internet
Author: User

Each program will be more than one version, each version of the function will be further optimized or adjusted, these features are briefly presented to the eager early adopters, this is the version of the new features.

The first time after the first installation or upgrade of the program, there will be three to four page function introduction page, screen browsing, and then the formal entry process. The same version of the program started two times without these introductory pages. This is the version.

This new feature is a realistic interface.

How do you implement this feature?

Requirements: First install or version upgrade, display new features; the second entry in the same version does not show the new feature.

Analysis: The program start will show different interface, that is, window loaded root controller Rootviewcontroller is not the same. How to make a program start, selectively load different controllers? Simply, the IF statement is resolved by judging it. So what is the condition of the If judgment? This is about the version, which is the version number.

Compare the version number and decide which controller to display.

Where do you compare the version number? Compares the version number of the currently running program and the version number stored in the program sandbox. Here are the following three scenarios:

The first time you run the program, the program sandbox does not save the version number at all. Current Program version number > Sandbox version number: Displays the new feature.

Program upgrade, current program version number > Sandbox version number: Displays the new feature. (or not equal to)

The program is not run for the first time, and the version number is saved in the sandbox. Current Program Version number = version number in sandbox: The new feature is not displayed.

1     //Create window, size equals screen size2Self.window =[[UIWindow alloc] Initwithframe:[uiscreen mainscreen].bounds];3     //Gets the bundle version number in the Info.plist of the current program, compared to the version number in the sandbox. 4     //key value of version number in Info.plist5NSString *key = (__bridge NSString *) Kcfbundleversionkey;6     //Current software version number7NSString *neweditionnum =[NSBundle Mainbundle].infodictionary[key];8     //the version number in the sandbox9Nsuserdefaults *defaults =[Nsuserdefaults standarduserdefaults];TenNSString *sandboxeditionnum =[Defaults stringforkey:key]; One     //Compare the size of the two (or judge [Neweditionnum Isequaltostring:sandboxeditionnum]) A     if([neweditionnum compare:sandboxeditionnum] = =nsordereddescending) { -         //The current version number is stored in the sandbox - [Defaults setobject:neweditionnum forkey:key]; the         //Synchronous Write - [Defaults synchronize]; -         //the root controller is the new feature controller -Self.window.rootViewController =[[Tyeditionviewcontroller alloc]init]; +}Else{ -         //the root controller is Tabbarcontroller +Self.window.rootViewController =[[Tytabbarcontroller alloc]init]; A     } at     //Show Window -[Self.window makekeyandvisible];
View Code

Version of iOS program implementation new feature display function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.