根据http://www.youtube.com/watch?v=u5XcVnHCQ0w的教程,我实现了共享的iAd横幅视图,以显示两个表的标头位置。两个表控制器位于导航控制器下。横幅视图显示在第一个表中,但未显示在下一个表中。
我在UItableViewControllers中实现的相同代码
- (AppDelegate *) appdelegate {
return (AppDelegate *)[[UIApplication sharedApplication] delegate];
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 100.0;
}
-(void) viewWillAppear:(BOOL)animated{
_UIiAD = [[self appdelegate] UIiAD];
_UIiAD.delegate = self;
[_UIiAD setFrame:CGRectMake(0,21,320,50)];
[self.view addSubview:_UIiAD];
}
-(void) viewWillDisappear:(BOOL)animated{
_UIiAD.delegate = nil;
_UIiAD=nil;
[_UIiAD removeFromSuperview];
}
-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
NSLog(@"ads loaded");
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[_UIiAD setAlpha:1];
[UIView commitAnimations];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
NSLog(@"ads not loaded");
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[_UIiAD setAlpha:0];
[UIView commitAnimations];
}