0

我的应用程序出现问题。
当我使用主页按钮进行多任务处理以移动到另一个应用程序时,它崩溃了,当我想再次回到我的应用程序时它崩溃了,我收到以下消息:

*** -[UIView convertRect:toView:]: message sent to deallocated instance 0x81e4020

自从我实施了“内部视图”广告以来,它就开始了。
我需要在我的代码中做些什么来让它消失吗?
我试图解决它但没有成功。
这是我的广告代码:

    CGRect frame = CGRectMake(0, 480, 320, 50);
    self.adBanner = [[UIView alloc] initWithFrame:frame];
    [self.view convertRect:adBanner.frame toView:nil];   --->This is a line i tried to put...
    [self.view addSubview:self.adBanner];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iaAdReceived:) name:@"iaAdReceived" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iaDefaultAdReceived:) name:@"iaDefaultAdReceived" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iaAdFailed:) name:@"IaAdFailed" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iaAdClicked:) name:@"IaAdClicked" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iaAdWillShow:) name:@"IaAdWillShow" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iaAdDidShow:) name:@"IaAdDidShow" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iaAdWillHide:) name:@"IaAdWillHide" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iaAdDidHide:) name:@"IaAdDidHide" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iaAdWillClose:) name:@"IaAdWillClose" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iaAdDidClose:) name:@"IaAdDidClose" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iaAdWillResize:) name:@"IaAdWillResize" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iaAdDidResize:) name:@"IaAdDidResize" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iaAdWillExpand:) name:@"IaAdWillExpand" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iaAdDidExpand:) name:@"IaAdDidExpand" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iaAppShouldSuspend:) name:@"IaAppShouldSuspend" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iaAppShouldResume:) name:@"IaAppShouldResume" object:nil];

    // Display ad
    if (![InneractiveAd DisplayAd:@"iOS_Test" withType:IaAdType_Banner withRoot:self.adBanner withReload:60 withParams:optionalParams])
    {
        [adBanner removeFromSuperview];
    }
}

    -(void) viewWillDisappear:(BOOL)animated
    {
            [super viewWillDisappear:animated];
            [adBanner removeFromSuperview];
    }

- (IBAction)iaAdReceived:(id)sender
   {
       // The ad view has finished loading a paid ad
   }

    - (IBAction)iaDefaultAdReceived:(id)sender
    {
        // The ad view has finished loading a default ad
    }

    - (IBAction)iaAdFailed:(id)sender
    {
        // The ad view has failed to load an ad
    }

    - (IBAction)iaAdClicked:(id)sender
    {
        // The ad has been clicked
    }

    - (IBAction)iaAdWillShow:(id)sender
    {
        // The ad is about to show
    }

    - (IBAction)iaAdDidShow:(id)sender
    {
        // The ad did show
    }

    - (IBAction)iaAdWillHide:(id)sender
    {
        // The ad is about to hide
    }

    - (IBAction)iaAdDidHide:(id)sender
    {
        // The ad did hide
    }

    - (IBAction)iaAdWillClose:(id)sender
    {
        // The ad is about to close
    }

    - (IBAction)iaAdDidClose:(id)sender
    {
        // The ad did close
    }

    - (IBAction)iaAdWillResize:(id)sender
    {
        // The ad is about to resize
    }

    - (IBAction)iaAdDidResize:(id)sender
    {
        // The ad did resize
    }

    - (IBAction)iaAdWillExpand:(id)sender
    {
        // The ad is about to expand
    }

    - (IBAction)iaAdDidExpand:(id)sender
    {
        // The ad did expand
    }

    - (IBAction)iaAppShouldSuspend:(id)sender
    {
        // The app should suspend (for example, when the ad expands)
    }

    - (IBAction)iaAppShouldResume:(id)sender
    {
        // The app should resume (for example, when the ad collapses)
    }

我附上了一个截图......
它可能是什么?
谢谢...

错误

4

1 回答 1

0

您的问题是运行时:

[self.view convertRect:adBanner.frame toView:nil];

你的观点不存在了。

在您的 appDelegate 中,您应该使用此方法:

- (void)applicationDidBecomeActive:(UIApplication *)application
{
/*
 Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
 */
}

无论如何,你试图用这条线实现什么?因为它返回一个你没有使用的 CGRect 。

于 2012-05-12T14:46:56.160 回答