0

4 つの異なるビュー コントローラーに 4 つのビデオがあり、アプリがランダムにクラッシュします。通常、最初にクリックしたもの (それが何であれ) が機能し、ボタンをクリックして他のビデオを再生すると、アプリがクラッシュします。通常、どちらを最初にクリックしてもかまいません。アプリの動作がおかしい。これが私が得るエラーコードです:

2013-07-26 10:56:40.590 Capture Controller[6558:907] -[ShoreViewController moviePlayBackDidFinish:]: 認識されないセレクターがインスタンス 0x2088bb20 に送信されました 2013-07-26 10:56:40.592 Capture Controller[6558:907] * アプリを終了していますキャッチされない例外 'NSInvalidArgumentException' のため、理由: '-[ShoreViewController moviePlayBackDidFinish:]: 認識されないセレクターがインスタンス 0x2088bb20 に送信されました' *First throw call stack: (0x339c43e7 0x3b84e963 0x339c7f31 0x339c664d 0x3391e208 0x33915349 0x3422cb7f 0x3484fec7 0x3484d251 0x33915349 0x3422cb7f 0x34866557 0x3486916f 0x34253b85 0x342537dd 0x3422dcbb 0x348ef73f 0x34253b85 0x342537dd 0x3422dcbb 0x348f208d 0x348f4149 0x348f1f2d 0x348f3d59 0x348f05d9 0x34862bcb 0x3484ddc7 0x33915349 0x3422cb7f 0x3484fc5b 0x3484f6a7 0x3484c055 0x49e61 0x358be087 0x358be03b 0x358be015 0x358bd8cb 0x358bddb9 0x357e65f9 0x357d38e1 0x357d31ef 0x374c75f7 0x374c7227 0x339993e7 libc++abi.dylib: 例外をスローして呼び出された終了

ここにいくつかのコードがあります:

EBViewController.h:

#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
#import "ReaderViewController.h"
@interface EBViewController : UIViewController <ReaderViewControllerDelegate>
@property (strong, nonatomic) MPMoviePlayerController *movieEBPlayer;
- (IBAction)playEBFilm:(id)sender;
- (IBAction)readEBDocument:(id)sender;
@end

EBViewController.m

#import "EBViewController.h"

@interface EBViewController ()

@end

@implementation EBViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UIButton *EBFilmButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [EBFilmButton addTarget:self action:@selector(playEBFilm) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:EBFilmButton];
    UIButton *readEBButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [readEBButton addTarget:self action:@selector(readEBDocument) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:readEBButton];
}
-(void)readEBDocument:(id)sender {
    NSString *file = [[NSBundle mainBundle] pathForResource:@"Rig" ofType:@"pdf"];
    ReaderDocument *document = [ReaderDocument withDocumentFilePath:file password:nil];
    if (document != nil)
    {
        ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document];
        readerViewController.delegate = self;
        readerViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        readerViewController.modalPresentationStyle = UIModalPresentationFullScreen;
        [self presentModalViewController:readerViewController animated:YES];
    }
}



-(void)playEBFilm:(id)sender
{
    NSString *path = [[NSBundle mainBundle] pathForResource:@"118409050" ofType:@"mp4"]; NSURL *url = [NSURL fileURLWithPath:path];   MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url]; [player play]; //- See more at: http://getsetgames.com/2009/12/20/iphonedev-advent-tip-20-how-to-play-a-video-with-mpmovieplayercontroller/#sthash.dznrF0UO.J8xsiXHT.dpuf

    _movieEBPlayer =  [[MPMoviePlayerController alloc]
                           initWithContentURL:url];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(moviePlayBackDidFinish:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:_movieEBPlayer];

    _movieEBPlayer.controlStyle = MPMovieControlStyleDefault;
    _movieEBPlayer.shouldAutoplay = YES;
    [self.view addSubview:_movieEBPlayer.view];
    [_movieEBPlayer setFullscreen:YES animated:YES];
}
- (void)dismissReaderViewController:(ReaderViewController *)viewController {
    [self dismissModalViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

PebbleViewController.h:

#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
#import "ReaderViewController.h"
@interface PebbleViewController : UIViewController <ReaderViewControllerDelegate>
@property (strong, nonatomic) MPMoviePlayerController *moviePebblePlayer;
- (IBAction)playPebbleFilm:(id)sender;
- (IBAction)readPebbleDocument:(id)sender;
@end

PebbleViewController.m:

#import "PebbleViewController.h"

@interface PebbleViewController ()

@end

@implementation PebbleViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UIButton *pebbleFilmButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [pebbleFilmButton addTarget:self action:@selector(playPebbleFilm) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:pebbleFilmButton];
    UIButton *readPebbleButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [readPebbleButton addTarget:self action:@selector(readPebbleDocument) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:readPebbleButton];
}
-(void)readPebbleDocument:(id)sender {
    NSString *file = [[NSBundle mainBundle] pathForResource:@"Rig" ofType:@"pdf"];
    ReaderDocument *document = [ReaderDocument withDocumentFilePath:file password:nil];
    if (document != nil)
    {
        ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document];
        readerViewController.delegate = self;
        readerViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        readerViewController.modalPresentationStyle = UIModalPresentationFullScreen;
        [self presentModalViewController:readerViewController animated:YES];
    }
}



-(void)playPebbleFilm:(id)sender
{
    NSString *path = [[NSBundle mainBundle] pathForResource:@"Pebble2" ofType:@"mov"]; NSURL *url = [NSURL fileURLWithPath:path];   MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url]; [player play]; //- See more at: http://getsetgames.com/2009/12/20/iphonedev-advent-tip-20-how-to-play-a-video-with-mpmovieplayercontroller/#sthash.dznrF0UO.J8xsiXHT.dpuf

    _moviePebblePlayer =  [[MPMoviePlayerController alloc]
                     initWithContentURL:url];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(moviePlayBackDidFinish:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:_moviePebblePlayer];

    _moviePebblePlayer.controlStyle = MPMovieControlStyleDefault;
    _moviePebblePlayer.shouldAutoplay = YES;
    [self.view addSubview:_moviePebblePlayer.view];
    [_moviePebblePlayer setFullscreen:YES animated:YES];
}
- (void)dismissReaderViewController:(ReaderViewController *)viewController {
    [self dismissModalViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

残りのビュー コントローラは基本的に同じですが、もちろん IBActions と moviePlayers の名前が異なります。どんなアドバイスでも大歓迎です!ありがとう!

4

1 に答える 1

2

次の名前のメソッドが表示されません。

- (void) moviePlayBackDidFinish:(NSNotification*)notification

ShoreViewControllerカット アンド ペーストしたコード スニペットのいずれか (ただし、いずれかのビュー コントローラーが実際に " " オブジェクトであるかどうかは明らかではありません)

コードに存在しない場合は、「インスタンスに送信された認識されないセレクター」のクラッシュが説明されます。

于 2013-07-26T19:37:36.420 に答える