1. Define Global member variables
@interface Appdelegate ()
@property (Strong, nonatomic) Uiimageview *adimageview;
@property (Strong, nonatomic) Uinavigationcontroller *rootnavi;
@end
2. Implement simple Advertising interface
@implementation Appdelegate
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {
Self.window = [[UIWindow alloc] Initwithframe:[uiscreen mainscreen].bounds];
textviewcontroller* MAINVC = [[Textviewcontroller alloc] init];
Uinavigationcontroller *nav = [[Uinavigationcontroller alloc] INITWITHROOTVIEWCONTROLLER:MAINVC];
Self.rootnavi = nav;
if ([[Uidevice currentdevice].systemversion Doublevalue] < 7.0) {
[Nav.navigationbar Setbartintcolor:[uicolor Clearcolor];
} else {
[Nav.navigationbar Settintcolor:[uicolor Clearcolor];
}
Note: Be sure to set the empty Rootviewcontroller
Uiviewcontroller *emptyview = [[Uiviewcontroller alloc] Initwithnibname:nil Bundle:nil];
Self. window. Rootviewcontroller = Emptyview;
Self.adimageview = [[Uiimageview alloc]initwithframe:cgrectmake (0, 0, ScreenWidth, screenheight)];
[Self.adimageview setimage:[uiimage imagenamed:@ "Bg_welcome"];
[Self.window AddSubview:self.adImageView];
[Self performselector: @selector (Removeadimageview) Withobject:nil Afterdelay:3];
Self.window.backgroundColor = [Uicolor Whitecolor];
[Self.window makekeyandvisible];
return YES;
}
3. Remove the ad page to reset the root controller
-(void) Removeadimageview
{
[UIView animatewithduration:0.3f animations:^{
Self.adImageView.transform = Cgaffinetransformmakescale (0.5f,0.5f);
Self.adImageView.alpha = 0.F;
} completion:^ (BOOL finished) {
[Self.adimageview Removefromsuperview];
Self.window.rootViewController = Self.rootnavi;
[Self RestoreRootViewController:self.rootNavi];
}];
}
-(void) Restorerootviewcontroller: (Uiviewcontroller *) Rootviewcontroller
{
typedef void (^animation) (void);
uiwindow* window = Self.window;
Rootviewcontroller.modaltransitionstyle = Uimodaltransitionstylecrossdissolve;
Animation Animation = ^{
BOOL oldstate = [UIView areanimationsenabled];
[UIView Setanimationsenabled:no];
Window.rootviewcontroller = Rootviewcontroller;
[UIView Setanimationsenabled:oldstate];
};
[UIView Transitionwithview:window
duration:0.5f
Options:uiviewanimationoptiontransitioncrossdissolve
Animations:animation
Completion:nil];
}
@end
4, if you need to achieve a countdown, skip only need to customize view to operate on OK
............
iOS launch page load ads