我只是想解雇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 show的代码是
-(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
。在其他选项卡的控制器中调用的方法仅为viewWillDisappear
和viewDidDisappear
。
答案 0 :(得分:2)
在我看来,MPMoviePlayerController
实例在viewDidAppear
之后被释放。我认为您应该将vc
设置为View Controller的属性或实例变量,以便它在View Controller的整个生命周期中保持不变。