3

却下したいのですUIAlertViewが、奇妙なバグで数日間できません...

のキャンセルボタンをタップするとUIAlertView、以下のコードが機能します。

- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{
    [alertView dismissWithClickedButtonIndex:buttonIndex animated:YES];
}

しかし、これらの行を通過した後、以下のメッセージでクラッシュします:

[MPMoviePlayerViewController isKindOfClass:]: message sent to deallocated instance 0x27f590

同じビューに、私は埋め込みます

MPMoviePlayerViewController.moviePlayer.view
[self.view addSubview:vc.moviePlayer.view];

何が起こったのか知っている人はいますか?ARC、iOS5.1を使用しています。さらに情報が必要な場合は、追加します。

前もって感謝します。

より詳しい情報:

コード内のすべてのメソッドにブレークポイントを設定しました。そして、私はそれが後にクラッシュすることを確認しましたclickedButtonAtIndex...

UIAlertView ショーを呼び出すためのコードは次のとおりです。

-(void)applicationDidBecomeActive:(NSNotification *)notification
{
    self.alert = hoge; // set delegate = self
    [self.alert show];
}

それらを呼び出した後、 が呼び出さviewDidAppearれます。vc.moviePlayer.view次のような埋め込み用のコードがあります

MPMoviePlayerViewController *vc;
vc = [[MPMoviePlayerViewController alloc] initWithContentURL:hogeURL];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(finishPreload:)
                                             name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification
                                           object:vc];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(finishPlayback:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:vc];

vc.view.frame = CGRectMake( 0, 0, 320, 440);

vc.moviePlayer.allowsAirPlay = YES;
vc.moviePlayer.shouldAutoplay = NO;
vc.moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
vc.moviePlayer.useApplicationAudioSession = NO;

[vc.moviePlayer.view setTag:310];

[self.view addSubview:vc.moviePlayer.view];

私のアプリには 3 つのタブがあり、そのうちの 2 つは埋め込みMPMoviePlayerViewController.moviePlayer.viewです。他のタブのコントローラーで呼び出されるメソッドはviewWillDisappearand viewDidDisappearonly です。

4

1 に答える 1

2

あなたのMPMoviePlayerControllerインスタンスは の後に割り当てが解除されたようviewDidAppearです。vcView Controllerの有効期間中持続するように、View Controllerのプロパティまたはインスタンス変数として設定する必要があると思います。

于 2012-06-10T11:37:38.320 に答える