首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIGestureRecognizer on MPMoviePlayerViewController

UIGestureRecognizer on MPMoviePlayerViewController
EN

Stack Overflow用户
提问于 2010-06-17 09:22:43
回答 1查看 1.4K关注 0票数 1

我想知道你们中是否有人遇到过类似的问题,当然,他们碰巧找到了一个合适或不太合适的解决方案/解决方案。

我正在使用一个MPMoviePlayerViewController,我试图在MPMoviePlayerViewControllers视图上添加一个滑动手势识别器。

moviePlayerViewController = [MPMoviePlayerViewController allocinitWithContentURL: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;

不管怎样,它“有点工作”,但是当我在运行中的电影播放器实例(无论是在模拟器中还是在设备上)上做手势来测试整个过程时,应用程序崩溃了,控制台状态

代码语言:javascript
复制
** -[CFRunLoopTimer invalidate]: message sent to deallocated instance 0xf074bb0

你们中有谁对这个话题有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-10-07 13:28:29

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

代码语言:javascript
复制
@property (nonatomic, retain) MPMoviePlayerViewController *moviePlayerViewController;

...along与相应的@synthesize声明您的类的实现文件。在分配对象时,您应该这样做:

代码语言:javascript
复制
  self.moviePlayerController = [[[MPMoviePlayerViewController alloc] initWithContentURL:@"yourUrl"] autorelease];

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3060352

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档