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