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