2011-12-04 63 views
0

我有一個iPhone應用程序,它使用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' 

下面是我的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:] 

另外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; 
    } 
} 

請幫我解決這個問題。謝謝。

+1

你沒有附加任何代碼:)試着打開NSZombieEnabled,可能你調用的對象是'nil',但很難說沒有代碼位。 –

+0

檢查您正在調用此方法的地方,bannerViewDidLoadAd :.在這些地方添加斷點並嘗試調試您的代碼。 – Robin

+0

我已經添加了NSZombie消息....只是要添加,我有一個列表和詳細控制器(它有iAd)....當我嘗試從詳細信息移動到列表視圖時,我得到了很少的消息。 。 – testndtv

回答

1

基本上你打電話bannerViewDidLoadAd:與錯誤的對象類型。看來你正在使用某種調度機制來做到這一點。當您爲該方法設置調度請求時,或者您未能保留該對象並將其刪除並替換爲NSType對象時,您指定了錯誤的對象。

因此,找到bannerViewDidLoadAd:在您的代碼中提及並確保與它一起使用的對象是正確的,並被適當保留。

+0

我已經添加了代碼,其中使用了bannerViewDidLoad ... – testndtv

+0

我已將代碼添加到我的原來的問題.. – testndtv

+0

@testndtv - 不,你沒有。 –

0

bannerViewDidLoad在代理被釋放後被調用,因此是殭屍消息。

我猜想這意味着你的廣告沒有被釋放,並且在你的控制器不在的時候,你的廣告仍然存在。

+0

嗨... thx很多...那麼我該怎麼做才能解決這個問題,或者我該如何確保廣告被髮布? – testndtv

+0

在你的視圖控制器的dealloc方法中,只需放入[banner release] – Randall

+0

實際上,我在viewDidLoad中擁有/ local裏面的橫幅代碼....我應該將它作爲插座還是其他東西移動...如果你可以提供有關實施的其他詳細信息... – testndtv