xcode iPhone 应用程序异常崩溃
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8375673/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iPhone app crashes with exception
提问by testndtv
I have an iPhone app which uses iAd...The app crashes sometime with the following message;
我有一个使用 iAd 的 iPhone 应用程序...该应用程序有时会崩溃并显示以下消息;
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType bannerViewDidLoadAd:]: unrecognized selector sent to instance 0x621cd10'
*** Call stack at first throw:
(
0 CoreFoundation 0x00e015a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f55313 objc_exception_throw + 44
2 CoreFoundation 0x00e030bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00d72966 ___forwarding___ + 966
4 CoreFoundation 0x00d72522 _CF_forwarding_prep_0 + 50
5 CoreFoundation 0x00d71c7d __invoking___ + 29
6 CoreFoundation 0x00d71b51 -[NSInvocation invoke] + 145
7 CoreFoundation 0x00d72a04 ___forwarding___ + 1124
8 CoreFoundation 0x00d72522 _CF_forwarding_prep_0 + 50
9 iAd 0x00[Switching to process 8860 thread 0x207]
0139f9 -[ADDistributedMessagingCenter messagePort:receivedMessage:withData:] + 251
10 iAd 0x00014012 ADMessagePortCallBack + 75
11 CoreFoundation 0x00db8f4c __CFMessagePortPerform + 396
12 CoreFoundation 0x00de2944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
13 CoreFoundation 0x00d42cf7 __CFRunLoopDoSource1 + 215
14 CoreFoundation 0x00d3ff83 __CFRunLoopRun + 979
15 CoreFoundation 0x00d3f840 CFRunLoopRunSpecific + 208
16 CoreFoundation 0x00d3f761 CFRunLoopRunInMode + 97
17 GraphicsServices 0x033fe1c4 GSEventRunModal + 217
18 GraphicsServices 0x033fe289 GSEventRun + 115
19 UIKit 0x002ffc93 UIApplicationMain + 1160
20 MyApp 0x00001ba8 main + 102
21 MyApp 0x00001b39 start + 53
)
terminate called after throwing an instance of 'NSException'
Below is my NSZombie message;
下面是我的 NSZombie 消息;
# Category Event Type RefCt Timestamp Address Size Responsible Library Responsible Caller
77 DetailController Zombie -1 04:01.914.883 0x5768bd0 0 iAd -[ADDistributedMessagingCenter messagePort:receivedMessage:withData:]
Also bannerViewDidLoadAd code;
还有bannerViewDidLoadAd 代码;
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if (!bannerIsVisible)
{
[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, -50); // if the banner is on top of the screen use 50
[UIView commitAnimations];
bannerIsVisible = YES;
}
}
Please help me fix the same. Thank you.
请帮我解决同样的问题。谢谢你。
回答by Hot Licks
Basically you're calling bannerViewDidLoadAd:
with the wrong object type. It appears that you're using some sort of dispatch mechanism to do this. Either you specified the wrong object when you set up the dispatch request for that method, or you failed to retain the object and it's been deleted and replaced with a NSType object.
基本上你bannerViewDidLoadAd:
用错误的对象类型调用。看来您正在使用某种调度机制来做到这一点。您在为该方法设置分派请求时指定了错误的对象,或者您未能保留该对象并且它已被删除并替换为 NSType 对象。
So find where bannerViewDidLoadAd:
is mentioned in your code and make sure the object being used with it is correct and is appropriately retained.
因此,找到bannerViewDidLoadAd:
您的代码中提到的位置,并确保与其一起使用的对象是正确的并且被适当地保留。
回答by Randall
bannerViewDidLoad is getting called after it's delegate is released, hence the zombie message.
bannerViewDidLoad 在它的委托被释放后被调用,因此是僵尸消息。
I would guess that this means your ad isn't being released and is sticking around after your controller is going away.
我猜这意味着您的广告没有被发布并且在您的控制器消失后仍然存在。