MPMoviePlayerViewController 上的 UIGestureRecognizer

发布于 2024-09-06 04:09:00 字数 1256 浏览 0 评论 0原文

我想知道你们中是否有人遇到过类似的问题,并且当然碰巧找到了合适或不太合适(但有效)的解决方案/解决方法。

我正在使用 MPMoviePlayerViewController,并且尝试将滑动手势识别器添加到 MPMoviePlayerViewControllers 视图上。

moviePlayerViewController = [[MPMoviePlayerViewController alloc]initWithContentURL:[NSURL URLWithString:currentChannel.StreamURI]];
[moviePlayerViewController.movi​​ePlayer setControlStyle:MPMovieControlStyleNone];
moviePlayerViewController.movi​​ePlayer.movi​​eSourceType = MPMovieSourceTypeStreaming;
moviePlayerViewController.movi​​ePlayer.shouldAutoplay = YES;
[moviePlayerViewController.movi​​ePlayer setScalingMode: MPMovieScalingModeAspectFit];

UISwipeGestureRecognizer *swipeGestureRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(previousChannel)];
swipeGestureRight.direction = UISwipeGestureRecognizerDirectionRight;
[myMoviePlayerViewController.view addGestureRecognizer:swipeGestureRight];
[self.view addSubview:moviePlayerViewController.view];

无论如何,它“有点有效”,但是当我通过在正在运行的电影播放器​​实例(无论是在模拟器中还是在设备上)上执行手势来测试整个事情时,应用程序崩溃并且控制台状态

** -[CFRunLoopTimer invalidate]: message sent to deallocated instance 0xf074bb0

你们中的任何一个人都这样做对这个话题有想法吗?

I'm wondering if any of you have encountered similar problems and of course happened to find a proper or not so proper (but working) solution/workaround.

I'm using a MPMoviePlayerViewController and I'm trying to a add Swipe-Gesture Recognizers onto the MPMoviePlayerViewControllers view.

moviePlayerViewController = [[MPMoviePlayerViewController alloc]initWithContentURL:[NSURL URLWithString:currentChannel.StreamURI]];
[moviePlayerViewController.moviePlayer setControlStyle:MPMovieControlStyleNone];
moviePlayerViewController.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
moviePlayerViewController.moviePlayer.shouldAutoplay = YES;
[moviePlayerViewController.moviePlayer setScalingMode: MPMovieScalingModeAspectFit];

UISwipeGestureRecognizer *swipeGestureRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(previousChannel)];
swipeGestureRight.direction = UISwipeGestureRecognizerDirectionRight;
[myMoviePlayerViewController.view addGestureRecognizer:swipeGestureRight];
[self.view addSubview:moviePlayerViewController.view];

anyway, it "kind of works" but when I'm testing the whole thing by doing the gesture on top of the running movie player instance (both, either in simulator or on device) the app crashes and the console states

** -[CFRunLoopTimer invalidate]: message sent to deallocated instance 0xf074bb0

does any of you have an idea on that topic?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一直在等你来 2024-09-13 04:09:00

看来 iOS 正在释放您的 MPMoviePlayerViewController 对象,然后稍后向它发送消息。我建议将该实例作为类的成员,然后实例化它的属性,例如:

@property (nonatomic, retain) MPMoviePlayerViewController *moviePlayerViewController;

...以及类的实现文件中相应的 @synthesize 声明。分配对象时,您应该执行以下操作:

  self.moviePlayerController = [[[MPMoviePlayerViewController alloc] initWithContentURL:@"yourUrl"] autorelease];

最后,通过在 dealloc 方法中将其设置为 nil 来释放该对象。

It seems that iOS is freeing your MPMoviePlayerViewController object and then sending a message to it later. I would suggest making the instance a member of your class, and then instantiating a property for it, eg:

@property (nonatomic, retain) MPMoviePlayerViewController *moviePlayerViewController;

...along with the corresponding @synthesize declaration your class' implementation file. When allocating your object, you should then do:

  self.moviePlayerController = [[[MPMoviePlayerViewController alloc] initWithContentURL:@"yourUrl"] autorelease];

And finally, release the object by setting it to nil in your dealloc method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文