0
當我嘗試加載視頻時,我收到一個引發的SIGABRT。以下是我的代碼。如果有人能讓我知道爲什麼我會得到這個錯誤,那會很好。正在爲該行引發信號:theMovie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];當我嘗試播放視頻時獲取SIGABRT信號(Objective-C)
兩個問題:我的代碼有什麼問題? SIGABRT通常意味着什麼?
#import "Video.h"
#import "MyManager.h"
#進口
@implementation Video
MPMoviePlayerController* theMovie;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)dealloc{
[theMovie release];
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
MyManager *sharedManager = [MyManager sharedManager];
NSString *tempName = sharedManager.vidName;
NSString *url = [[NSBundle mainBundle] pathForResource:sharedManager.vidName ofType:@"mp4"];
theMovie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallBack:) name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie];
theMovie.scalingMode = MPMovieScalingModeAspectFit;
[theMovie.view setFrame:self.view.bounds];
[self.view addSubview:theMovie.view];
[theMovie play];
}
-(void)movieFinishedCallBack:(NSNotification *) aNotification{
theMovie = [aNotification object];
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie];
[theMovie.view removeFromSuperview];
[theMovie pause];
[theMovie stop];
}
-(void) viewWillDisappear:(BOOL)animated{
[theMovie pause]; // assume myMoviePlayer is an instance variable
[theMovie stop];
theMovie = nil;
[theMovie release];
}
- (void)viewDidUnload
{
[theMovie pause]; // assume myMoviePlayer is an instance variable
[theMovie stop];
theMovie = nil;
[theMovie release];
[super viewDidUnload];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
你知道如何查看崩潰報告嗎?檢查可能會給你一些線索。這可能是由於一個未捕獲的異常 – tams 2012-03-24 20:48:59
@tams我對iPhone開發非常陌生,這是我在Objective-c中的第一個項目。我不知道如何查看崩潰報告。我該如何解決這個問題?這正是輸出日誌中的內容嗎?在日誌中說:拋出'NSException' – 2012-03-24 20:52:12
的實例後調用terminate,我認爲如果你是新的,你可以開始調試你的視圖的確實加載方法。在方法的開始處放置一個斷點並逐步執行代碼。確保你所有的變量都是正確的,並且你的字符串設置正確。問題可能在那裏。 – tams 2012-03-24 20:57:51