MPMoviePlayerViewController 上的 UIGestureRecognizer
我想知道你们中是否有人遇到过类似的问题,并且当然碰巧找到了合适或不太合适(但有效)的解决方案/解决方法。
我正在使用 MPMoviePlayerViewController,并且尝试将滑动手势识别器添加到 MPMoviePlayerViewControllers 视图上。
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];
无论如何,它“有点有效”,但是当我通过在正在运行的电影播放器实例(无论是在模拟器中还是在设备上)上执行手势来测试整个事情时,应用程序崩溃并且控制台状态
** -[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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来 iOS 正在释放您的 MPMoviePlayerViewController 对象,然后稍后向它发送消息。我建议将该实例作为类的成员,然后实例化它的属性,例如:
...以及类的实现文件中相应的
@synthesize
声明。分配对象时,您应该执行以下操作:最后,通过在
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:...along with the corresponding
@synthesize
declaration your class' implementation file. When allocating your object, you should then do:And finally, release the object by setting it to
nil
in yourdealloc
method.