gpt4 book ai didi

ios - 应用程序因多个视频而崩溃

转载 作者:行者123 更新时间:2023-11-28 22:29:28 24 4
gpt4 key购买 nike

我在四个不同的 View Controller 中有四个视频,它们随机地使应用程序崩溃。通常我点击的第一个(不管它是哪个)会起作用,然后如果我点击按钮播放任何其他视频,应用程序就会崩溃。一般来说,我先点击哪个并不重要。该应用程序行为异常。这是我得到的错误代码:

2013-07-26 10:56:40.590 Capture Controller[6558:907] -[ShoreViewController moviePlayBackDidFinish:]: unrecognized selector sent to instance 0x2088bb20 2013-07-26 10:56:40.592 Capture Controller[6558:907] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ShoreViewController moviePlayBackDidFinish:]: unrecognized selector sent to instance 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 0x3399938b 0x3399820f 0x3390b23d 0x3390b0c9 0x374c633b 0x358272b9 0x26a2d 0x3bc7bb20) libc++abi.dylib: terminate called throwing an exception

这是一些代码:

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

其余的 View Controller 基本相同,当然只是 IBAction 和 moviePlayers 的名称不同。任何建议将不胜感激!谢谢!

最佳答案

我没有看到名为的方法:

- (void) moviePlayBackDidFinish:(NSNotification*)notification

在您剪切和粘贴的任何代码片段中(尽管这两个 View Controller 是否实际上是您的“ShoreViewController”对象并不明显)

如果它不存在于您的代码中,那将解释“无法识别的选择器发送到实例”崩溃。

关于ios - 应用程序因多个视频而崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17889551/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com