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