那么我设计的iPhone应用程序将在本地播放视频。当我点击模拟器中的按钮时,它会完美播放,但当它停止时或手动结束时,它会崩溃,并一直给我提出这个问题。我尝试清理,构建,分析并再次运行,但仍然一样。任何帮助?iphone ios xcode 4.2 - EXC_BAD_ACCESS信号
我的代码是:
MoviePlayerViewController.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <MediaPlayer/MediaPlayer.h>
@interface MoviePlayerViewController : UIViewController {
}
-(IBAction)playMovie:(id)sender;
@end
和MoviePlayerViewController.m主钻头
- (IBAction)playMovie:(id)sender {
NSString *movpath = [[NSBundle mainBundle] pathForResource:@"think" ofType:@"mp4"];
MPMoviePlayerViewController *mpviewController = [[MPMoviePlayerViewController alloc]
initWithContentURL:[NSURL fileURLWithPath:movpath]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[self.view addSubview:mpviewController.view];
MPMoviePlayerController *mp = [mpviewController moviePlayer];
[mp prepareToPlay];
mp.scalingMode=MPMovieScalingModeAspectFill;
[[mpviewController moviePlayer] play];
}
- (void)playbackFinishedCallback:(NSNotification *)notification {
MPMoviePlayerViewController *mpviewController = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:mpviewController];
[mpviewController.view removeFromSuperview];
[mpviewController release];
}
使用僵尸运行你的应用程序仪器。它会告诉你到底是什么问题。 – edc1591 2012-03-01 18:06:04
如何?在新的Xcode是完全不同的。我搜索了它,但没有找到它.. – 2012-03-01 18:07:20
如果你进入你的计划设置有一个僵尸复选框。它会导致你试图访问的僵尸对象被打印在日志中。然后你可以看到它们是什么并修复它们:) – 2012-03-01 18:09:40