iOS launch page load ads

Source: Internet
Author: User

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

Related Article

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.