2
2
2and2015-08-13 13:52:47
Objective-C
2and, 2015-08-13 13:52:47

Internet check and iAd?

Hello. I have been suffering for several days with iAd, now the last problem was the display of ads when the Internet disappears in the application. That is, if you abruptly switch to "Airplane Mode", thereby turning off the Internet, then the banner "You're Connected To iAd" remains, when you click it, it opens (it's standard where the animation is with a checkmark), when you return to the application, there is no longer a banner - according to this parts are ok.
But if you turn on the Internet, the banner does not appear. How to make a check every time you enter the application?
It's just that everything is complicated by the fact that I made a Tab Bar application with four Table View Controllers, and I will have to check on each of them ...
Here is the code

- (void)viewDidLoad {
    [super viewDidLoad];
    _UIiAD = [[self appdelegate] UIiAD];
    _UIiAD.delegate = self;
}

-(void) viewWillAppear:(BOOL)animated{
    _UIiAD = [[self appdelegate] UIiAD];
    _UIiAD.delegate = self;
    [_UIiAD setFrame:CGRectMake(0, self.view.frame.size.height - 99, 320, 50)];
    [_UIiAD setAlpha:0];
    [self.view addSubview:_UIiAD];    
}

-(void) viewWillDisappear:(BOOL)animated{
    _UIiAD.delegate = nil;
    _UIiAD=nil;
    [_UIiAD removeFromSuperview];
}

//Успешная загрузка
-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1];
    [_UIiAD setAlpha:1];
    [UIView commitAnimations];
}

//Ошибка загрузки
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1];
    [_UIiAD setAlpha:0];
    [UIView commitAnimations];
}

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
2
2and, 2015-08-13
@2and

Wow ... I found a solution, I searched for several hours on Google, about checking the Internet with iAd and did not find anything sensible, I decided to search just about checking the Internet and did everything in 5 minutes ( Decision ).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question