那麼我設計的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