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 に答える