3 天来我真的很沮丧,我检查了一切,它工作得很好。没有错误,模拟器上没有警告,但是在 iPad 上启动时,它得到了这个 SIGABRT 错误。我正在使用 Xcode 4.3 和 ARC 激活。这是我的代码:
.h 文件:
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
@interface videothumbnailViewController : UIViewController {
NSURL *videoURL;
NSURL *videoURL2;
MPMoviePlayerController *player;
MPMoviePlayerController *player2;
UIScrollView *scrollView;
}
@property (nonatomic, retain) IBOutlet UIScrollView *scrollView;
@property (nonatomic, retain) MPMoviePlayerController *player;
@property (nonatomic, retain) MPMoviePlayerController *player2;
-(IBAction)stopmovie:(id)sender;
-(IBAction)playmovie:(id)sender;
-(IBAction)playmovie2:(id)sender;
@end
和实现文件:
#import "videothumbnailViewController.h"
#import "MediaPlayer/MediaPlayer.h"
@interface videothumbnailViewController ()
@end
@implementation videothumbnailViewController
@synthesize scrollView;
@synthesize player;
@synthesize player2;
-(IBAction)playmovie2:(id)sender {
// [player stop];
NSString *path2 = [[NSBundle mainBundle] pathForResource:@"test2.mov" ofType:nil];
videoURL2 = [NSURL fileURLWithPath:path2];
player2 = [[MPMoviePlayerController alloc] initWithContentURL:videoURL2];
player2.view.frame = CGRectMake(676, 0, 605, 339);
player2.scalingMode = MPMovieScalingModeFill;
[scrollView addSubview:player2.view];
player2.controlStyle = MPMovieControlStyleNone;
[player2.backgroundView addSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"test2.png"]]];
player2.view.backgroundColor = [UIColor clearColor];
[player2 play];
player2.repeatMode = MPMovieRepeatModeOne;
}
-(IBAction)playmovie:(id)sender {
[player2 stop];
NSString *path = [[NSBundle mainBundle] pathForResource:@"test.mov" ofType:nil];
videoURL = [NSURL fileURLWithPath:path];
player = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
player.view.frame = CGRectMake(0, 0, 605, 339);
player.scalingMode = MPMovieScalingModeFill;
[scrollView addSubview:player.view];
player.controlStyle = MPMovieControlStyleNone;
[player.backgroundView addSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"test.png"]]];
player.view.backgroundColor = [UIColor clearColor];
[player play];
player.repeatMode = MPMovieRepeatModeOne;
}
-(IBAction)stopmovie:(id)sender {
[player stop];
}
- (void)viewDidLoad {
[super viewDidLoad];
NSString *path2 = [[NSBundle mainBundle] pathForResource:@"test2.mov" ofType:nil];
videoURL2 = [NSURL fileURLWithPath:path2];
player2 = [[MPMoviePlayerController alloc] initWithContentURL:videoURL2];
player2.view.frame = CGRectMake(676, 0, 605, 339);
player2.scalingMode = MPMovieScalingModeFill;
[scrollView addSubview:player2.view];
player2.controlStyle = MPMovieControlStyleNone;
player2.view.backgroundColor = [UIColor clearColor];
[player2 stop];
[scrollView setContentSize:CGSizeMake(1300, 339)];
NSString *path = [[NSBundle mainBundle] pathForResource:@"test.mov" ofType:nil];
videoURL = [NSURL fileURLWithPath:path];
player = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
player.view.frame = CGRectMake(0, 0, 605, 339);
player.scalingMode = MPMovieScalingModeFill;
[scrollView addSubview:player.view];
player.controlStyle = MPMovieControlStyleNone;
[player.backgroundView addSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"test.png"]]];
player.view.backgroundColor = [UIColor clearColor];
player.repeatMode = MPMovieRepeatModeOne;
[player play];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
@end