0

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
4

1 回答 1

0

请尝试添加这样的异常断点:

  1. 转到 Xcode 中的断点窗格,然后单击底部的加号按钮 在此处输入图像描述

  2. 单击添加异常断点
    在此处输入图像描述

  3. 点击完成
    在此处输入图像描述

调试器不应停在抛出异常的行。

希望这可以帮助!

于 2012-06-20T07:40:51.387 回答