I just want to dismiss UIAlertView but I can't with a strange bug for some days...
After tapping cancel button on UIAlertView, Codes below works.
- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
[alertView dismissWithClickedButtonIndex:buttonIndex animated:YES];
}
But After passing these lines, it makes crash with message below:
[MPMoviePlayerViewController isKindOfClass:]: message sent to deallocated instance 0x27f590
On the same view, I embed
MPMoviePlayerViewController.moviePlayer.view
[self.view addSubview:vc.moviePlayer.view];
Does Anybody know what happend? I use ARC, iOS5.1. If you need more information, I do add them.
Thank you in advance.
more info:
I set breakpoints on all methods in my code.
And I made sure that it crashes after clickedButtonAtIndex...
codes for calling UIAlertView show are
-(void)applicationDidBecomeActive:(NSNotification *)notification
{
self.alert = hoge; // set delegate = self
[self.alert show];
}
after calling them, viewDidAppear's called.
There are codes for enbedding vc.moviePlayer.view like
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];
My app has 3 tabs, 2 of them's embed MPMoviePlayerViewController.moviePlayer.view. Method called in the other tabs's controller are viewWillDisappear and viewDidDisappear only.
It seems to me that your MPMoviePlayerController instance is deallocated after viewDidAppear. I think you should set vc as a property or instance variable of the View Controller so that it persists throughout the lifetime of the View Controller.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With