About the App launch boot page module
Date: June 14, 2016
Zhao Rui
- Module usage Instructions
The exposed interface of the module is-(void) Showguideviewwithimages: (Nsarray *) images; the name array of the image of the boot page needs to be passed in.
@interface guidemanager:nsobject/*** implementation: App boot map * * @param images the name array */-(void) Showguideviewwithimages: ( Nsarray *) images;
Note: Calling this method requires a-(void) Viewdidappear: (BOOL) animated; Called in.
The main idea is to store the version number the first time the user starts, and then each boot page is compared to the version number stored in the sandbox, and if it is consistent, skip the guide diagram
-(void) Showguideviewwithimages: (Nsarray *) images{nsstring * key = @ "cfbundleshortversionstring";//Get Current version number NSString * versionstring = [NSBundle mainbundle].infodictionary[key];//Gets the version number stored in the sandbox nsstring * sandboxstring = [[NSUserDefaults] Standarduserdefaults] stringforkey:key];//Determine whether two version numbers are equal, and then determine whether to start the boot diagram if (![ VersionString isequaltostring:sandboxstring]&& Self.window = = nil) {self.images = images; Self.pageControl.numberOfPages = Images.count;self.window = [UIApplication Sharedapplication].keywindow; [Self.window AddSubview:self.guideView]; [Self.window addsubview:self.pagecontrol];//stores the current version number to the sandbox [[Nsuserdefaults standarduserdefaults] SetValue: VersionString Forkey:key]; [[Nsuserdefaults standarduserdefaults] synchronize];}}
In the function implementation of this module there are two options for the transfer of parameters, one is the path of the incoming picture, the other is the name of the incoming picture, As a result of the general use of Xcode assets.xcassets to manage the image, and so manage the picture, the default picture is not added to the buddle, so if the introduction of the path to the picture will result in a return value of nil, so choose to pass in the image name, you can simplify the code, but also to implement functionality.
You can refer to http://blog.chinaunix.net/uid-11121450-id-3460066.html about how to handle the Pathforresource return value of nil.
- About the pits encountered during the development of the module
1> first is the method of the external calling interface, usually called in the Viewdidload method, but if the method to invoke the start page here will cause the boot picture to add failed, because at this time the Keywindow is nil, so add not up.
2> does not really understand the meaning of Keywindow, Keywindow takes the current active window rather than the bottom of the view window. And in this case, the success is added to the underlying window, and the final guide page is covered with a layer of view that cannot be interacted with.
3> try to remove the view at the end of the boot page, while leaving the space blank to prevent the wild pointer from collapsing.
-Program Run
The specific wording of the Guide page is very simple can be used Scrollerview or CollectionView, as long as the last add a button, here will not write
App Launch page