Load AD---iOS when application program starts

Source: Internet
Author: User

The app will load the splash image when it launches, how do we make an ad page?

Idea: After the boot is complete, create a controller that loads the ad, and then when the ad ends, we're going to load the main frame content

First we create an ad controller

@interface Abadviewcontroller () @property (weak, nonatomic) iboutlet UIButton *adjumpbtn;//Skip button @property (weak, nonatomic) Iboutlet uiimageview *adimageview;//Loading interface picture @property (weak, nonatomic) Iboutlet UIView *adview; @property ( Nonatomic, weak) Uiimageview *imageview;//load the image of the advertisement @property (nonatomic, strong) Abadmodel *model; @property (Nonatomic,        Weak) Nstimer *timer, @end @implementation abadviewcontroller-(Uiimageview *) imageview{if (_imageview = = nil) {        Uiimageview *imageview = [[Uiimageview alloc] init];        _imageview = ImageView; [Self.        ADView Addsubview:imageview];        _imageview.userinteractionenabled = YES; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initwithtarget:self action: @selector (TAP)];//add gesture [im            Ageview Addgesturerecognizer:tap]; } return _imageview;}    -(void) tap{uiapplication *app = [UIApplication sharedapplication]; if ([app Canopenurl:[nsurl urlwithstring:@ "http://sina.cn/?wm=4007"]) {[App Openurl:[nsurl urlwithstring:@ "http://sina.cn/?wm=4007"];    }}-(void) viewdidload {[Super viewdidload];    [Self Setlau];    [Self loaddata]; _timer = [Nstimer scheduledtimerwithtimeinterval:1 target:self selector: @selector (changetime) Userinfo:nil repeats: yes];//Add timer, countdown time}-(void) setlau{self. Adimageview.image = [UIImage imagenamed:@ "launchimage-568h"];} -(void) loaddata{//Use Sdimage framework asynchronous download ad interface assignment with Self.imageview}-(ibaction) Adbtnclick: (ID) Sender {uiapplication *app = [    UIApplication Sharedapplication];    App.keyWindow.rootViewController = [[Abtbcontroller alloc] init];    [_timer invalidate];//destroys the timer, otherwise it will not release}-(void) changetime{static int time = 3;    if (time <= 0) {[Self adbtnclick:nil];    } time--;    NSString *str = [NSString stringwithformat:@ "skips%d Seconds", time]; [Self. ADJUMPBTN settitle:str forstate:uicontrolstatenormal];//Use timer countdown time, Time end Trigger button event}

  

Load AD---iOS when application program starts

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.