我在崩溃前的4.3模拟器上出现此错误。它在5.1上运行得很好。当我完全取出iAd代码时,它在4.3上工作正常。应用程序是使用arc设计的5.1。
[LinkViewController bannerView:didFailToReceiveAdWithError:]: message sent to deallocated instance
我在所有例外中都设置了一个断点。我已经运行它与NSZombie,NSDebug和NSMallocStackLogging全部启用。我怎样才能找到解除分配的内容?
这是主题:
Thread 1, Queue : com.apple.main-thread
#0 0x0018e657 in ___forwarding___ ()
#1 0x0018e522 in _CF_forwarding_prep_0 ()
#2 0x005ef0f0 in -[ADBannerView _sanitizeAndForwardErrorToDelegate:] ()
#3 0x0018dc7d in __invoking___ ()
#4 0x0018db51 in -[NSInvocation invoke] ()
#5 0x0018ea04 in ___forwarding___ ()
#6 0x0018e522 in _CF_forwarding_prep_0 ()
#7 0x005f59f9 in -[ADDistributedMessagingCenter messagePort:receivedMessage:withData:] ()
#8 0x005f6012 in ADMessagePortCallBack ()
#9 0x001d4f4c in __CFMessagePortPerform ()
#10 0x001fe944 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#11 0x0015ecf7 in __CFRunLoopDoSource1 ()
#12 0x0015bf83 in __CFRunLoopRun ()
#13 0x0015b840 in CFRunLoopRunSpecific ()
#14 0x0015b761 in CFRunLoopRunInMode ()
#15 0x020331c4 in GSEventRunModal ()
#16 0x02033289 in GSEventRun ()
#17 0x009bbc93 in UIApplicationMain ()
#18 0x00003125 in main at /Developer/Cecilia's Programs/Story/Story/main.m:17
#19 0x000029b5 in start ()
这是我的代码:
- (void) createAdBannerView
{
Class classAdBannerView = NSClassFromString (@"ADBannerView");
if (classAdBannerView != nil)
{
self.adBannerView = [[classAdBannerView alloc] initWithFrame:CGRectZero];
[_adBannerView setRequiredContentSizeIdentifiers:[NSSet setWithObjects: ADBannerContentSizeIdentifierLandscape, nil]];
[_adBannerView setCurrentContentSizeIdentifier: ADBannerContentSizeIdentifierLandscape];
}
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
[_adBannerView setFrame:CGRectOffset([_adBannerView frame], 0, -32)];
}
else
{
[_adBannerView setFrame:CGRectOffset([_adBannerView frame], 0, -66)];
}
[_adBannerView setDelegate:self];
[self.view addSubview:_adBannerView];
}
- (void)fixupAdView
{
if (_adBannerView != nil)
{
[_adBannerView setCurrentContentSizeIdentifier: ADBannerContentSizeIdentifierLandscape];
[UIView beginAnimations:@"fixupViews" context:nil];
if (_adBannerViewIsVisible)
{
CGRect adBannerViewFrame = [_adBannerView frame];
adBannerViewFrame.origin.x = 0;
adBannerViewFrame.origin.y = 20;
[_adBannerView setFrame:adBannerViewFrame];
CGRect iAdViewFrame = _iAdView.frame;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
iAdViewFrame.origin.y = 20;
iAdViewFrame.size.height = self.view.frame.size.height - 32;
_iAdView.frame = iAdViewFrame;
}
else
{
iAdViewFrame.origin.y = 20;
iAdViewFrame.size.height = self.view.frame.size.height - 66;
_iAdView.frame = iAdViewFrame;
}
}
else
{
CGRect adBannerViewFrame = [_adBannerView frame];
adBannerViewFrame.origin.x = 0;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
adBannerViewFrame.origin.y = -52;
}
else
{
adBannerViewFrame.origin.y = -86;
}
[_adBannerView setFrame:adBannerViewFrame];
CGRect iAdViewFrame = _iAdView.frame;
iAdViewFrame.origin.y = 0;
iAdViewFrame.size.height = self.view.frame.size.height;
_iAdView.frame = iAdViewFrame;
}
[UIView commitAnimations];
}
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if (!_adBannerViewIsVisible)
{
_adBannerViewIsVisible = YES;
[self fixupAdView];
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (_adBannerViewIsVisible)
{
_adBannerViewIsVisible = NO;
[self fixupAdView];
}
}
- (void) viewWillAppear:(BOOL)animated
{
[self fixupAdView];
}
- (void)viewDidLoad
{
[self createAdBannerView];
}
提前感谢你们给我的任何帮助!