【发布时间】:2012-06-10 10:21:13
【问题描述】:
我只是想解雇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。其他标签的控制器中调用的方法只有viewWillDisappear和viewDidDisappear。
【问题讨论】:
-
问题不在于 UIAlertView,而是在按下取消按钮后调用的函数。在您的代码中放置一个断点并检查它到底在哪里崩溃。并向我们展示您在哪里启动 MPMoviePlayerViewController,在代码中您是否使用 isKinfOfClass 方法检查任何实例是否为 MPMovieViewController?
-
感谢您的回复。我在我的问题中添加了更多信息。如果您需要更多信息,请写下来。我真的很感激。
标签: iphone ios xcode mpmovieplayercontroller uialertview