我将UAd添加到UITableView底部的UIVIew中,快速向上/向下滚动时也会出错。
代码
- (void)viewDidLoad {
//NSLog(@"viewDidLoad");
if(NSClassFromString(@"ADBannerView") != nil) {
ADBannerView *adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0,0,0,0)];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
adView.delegate = self;
adView.hidden = YES;
[self.iAdBanner addSubview:adView];
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// assumes the banner view is at the top of the screen.
adView.frame = CGRectOffset(adView.frame, 0, -150);
[UIView commitAnimations];
//[adView release];
}
else {
//NSLog(@"iad not available");
}
[super viewDidLoad];
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
//NSLog(@"bannerViewDidLoadAd");
//[self moveBannerViewOnscreen];
if (banner.hidden)
{
[UIView beginAnimations:@"animateAdBannerOn" context:NULL];
// assumes the banner view is offset 50 pixels so that it is not visible.
banner.frame = CGRectOffset(banner.frame, 0, 150);
banner.hidden = NO;
[UIView commitAnimations];
//self.bannerIsVisible = YES;
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
//NSLog(@"bannerView error");
//[self moveBannerViewOffscreen];
//*
if (!banner.hidden)
{
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// assumes the banner view is at the top of the screen.
banner.frame = CGRectOffset(banner.frame, 0, -150);
[UIView commitAnimations];//*/
banner.hidden = YES;
}
}
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave {
//NSLog(@"bannerViewActionShouldBegin");
//[super bannerViewActionShouldBegin:banner willLeaveApplication:willLeave];
return YES;
}
- (void)bannerViewActionDidFinish:(ADBannerView *)banner {
//NSLog(@"bannerViewActionDidFinish");
}
错误记录
2010-07-27 11:58:58.547 PantipCafe[730:307] ******* Accessibility Status Changed: On
2010-07-27 11:58:59.068 PantipCafe[730:307] ********** Loading AX for: com.ragopor.pantip ************
2010-07-27 11:59:01.345 PantipCafe[730:307] CPDistributedMessagingCenter attempting to send reply to a dead port. Reply keys: (null)
2010-07-27 11:59:05.182 PantipCafe[730:307] CPDistributedMessagingCenter attempting to send reply to a dead port. Reply keys: (null)
2010-07-27 11:59:11.653 PantipCafe[730:307] CPDistributedMessagingCenter attempting to send reply to a dead port. Reply keys: (null)
2010-07-27 11:59:13.224 PantipCafe[730:307] CPDistributedMessagingCenter attempting to send reply to a dead port. Reply keys: (null)
2010-07-27 11:59:25.437 PantipCafe[730:307] CPDistributedMessagingCenter attempting to send reply to a dead port. Reply keys: (null)
2010-07-27 11:59:28.434 PantipCafe[730:307] CPDistributedMessagingCenter attempting to send reply to a dead port. Reply keys: (null)
2010-07-27 12:00:06.220 PantipCafe[730:307] CPDistributedMessagingCenter attempting to send reply to a dead port. Reply keys: (null)
2010-07-27 12:00:10.241 PantipCafe[730:307] -[__NSCFType bannerView:didFailToReceiveAdWithError:]: unrecognized selector sent to instance 0x544e9b0
2010-07-27 12:00:10.265 PantipCafe[730:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType bannerView:didFailToReceiveAdWithError:]: unrecognized selector sent to instance 0x544e9b0'
*** Call stack at first throw:
(
0 CoreFoundation 0x3303ffd3 __exceptionPreprocess + 114
1 libobjc.A.dylib 0x309e7871 objc_exception_throw + 24
2 CoreFoundation 0x33043a77 -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
3 CoreFoundation 0x33042f15 ___forwarding___ + 508
4 CoreFoundation 0x32fd5680 _CF_forwarding_prep_0 + 48
5 iAd 0x31bdc25d -[ADBannerView _sanitizeAndForwardErrorToDelegate:] + 48
6 iAd 0x31bdafcf -[ADBannerView sessionBannerViewDidFailToReceiveAd:withError:] + 38
7 iAd 0x31be8ca9 -[ADSession bannerViewDidFailToReceiveAddWithErrorMessage:userInfo:auditToken:] + 116
8 AppSupport 0x32a4d0b5 -[CPDistributedMessagingCenter _dispatchMessageNamed:userInfo:reply:auditToken:] + 172
9 AppSupport 0x32a4df87 processMessage + 514
10 AppSupport 0x32a4e1cb _CPDMMessage + 74
11 AppSupport 0x32a4ede9 _XMessage + 248
12 AppSupport 0x32a412c3 migHelperRecievePortCallout + 138
13 CoreFoundation 0x33015aab __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
14 CoreFoundation 0x3301784f __CFRunLoopDoSource1 + 166
15 CoreFoundation 0x3301862d __CFRunLoopRun + 520
16 CoreFoundation 0x32fc18eb CFRunLoopRunSpecific + 230
17 CoreFoundation 0x32fc17f3 CFRunLoopRunInMode + 58
18 GraphicsServices 0x302dd673 GSEventRunModal + 114
19 GraphicsServices 0x302dd71f GSEventRun + 62
20 UIKit 0x33720cff -[UIApplication _run] + 402
21 UIKit 0x3371f8c7 UIApplicationMain + 670
22 PantipCafe 0x00002ceb main + 42
23 PantipCafe 0x00002c88 start + 52
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
(gdb)
答案 0 :(得分:0)
使用头文件可能更容易回答,但是您是否设置了接口来实现委托接口?您需要在UIViewController中执行此操作才能捕获iAd消息。并且不要忘记#import。
如果您使用Interface Builder进行设置 - 而AFAICT则没有,只需动态创建iAd - 那么通过连接iAd委托将iAd委托设置到您的视图还有其他问题到“文件所有者”套接字。
无论如何,检查你的头文件,我希望这对你们两个都有帮助。