Push-to-boot when entering a new version

Source: Internet
Author: User

XX effect

The specific code is as follows first create a new Xmgpushguideview class XMGPushGuideView.h file #import <UIKit/UIKit.h>

@interface Xmgpushguideview:uiview
/** Loading Xib */
+ (instancetype) Guideview;
/** judge the current version number, and determine whether to load the recommended boot page */
+ (void) show;
@end xmgpushguideview.m file #import "XMGPushGuideView.h"

@implementation Xmgpushguideview

+ (Instancetype) guideview{

return [[[NSBundle Mainbundle] Loadnibnamed:nsstringfromclass (self) owner:nil options:nil] lastobject];
}
-(ibaction) Close {
[Self removefromsuperview];
}

+ (void) show{

NSString *[email protected] "cfbundleshortversionstring";

Get the version number of the current software
NSString *currentversion = [NSBundle Mainbundle].infodictionary[key];

Get the version number of the store in the sandbox
NSString *sanboxversion=[[nsuserdefaults Standarduserdefaults] stringforkey:key];

if (![ CurrentVersion Isequaltostring:sanboxversion]) {

Get the current window
UIWindow *window=[uiapplication Sharedapplication].keywindow;


Xmgpushguideview *guideview=[xmgpushguideview Guideview];
Guideview.frame=window.bounds;
[Window Addsubview:guideview];
Store version number
[[Nsuserdefaults Standarduserdefaults] setobject:currentversion Forkey:key];
Store the version number in the sandbox now
[[Nsuserdefaults standarduserdefaults] synchronize];
}

}
@end while in APPDELEGATE.M file-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (NSDictionary *) Launchoptions {
Override point for customization after application launch.

Create window
Self.window=[[uiwindow Alloc]init];
Self.window.frame=[uiscreen Mainscreen].bounds;

Setting the window's heel controller
Self.window.rootviewcontroller=[[xmgtabbarcontroller Alloc]init];


Display window
[Self.window makekeyandvisible];



Show Push Boot
[Xmgpushguideview show];


return YES;}

Push-to-boot when entering a new version

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.