我想知道你们是否遇到过类似的问题,当然恰好找到了一个合适的或不那么合适的(但有效的)解决方案/解决方法。
我正在使用MPMoviePlayerViewController,我正在尝试在MPMoviePlayerViewControllers视图中添加Swipe-Gesture Recognizers。
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];
无论如何,它“有点工作”但是当我通过在运行的电影播放器实例(无论是在模拟器还是在设备上)上做手势来测试整个事情时,应用程序崩溃并且控制台声明< / p>
** -[CFRunLoopTimer invalidate]: message sent to deallocated instance 0xf074bb0
你们是否对这个话题有所了解?
答案 0 :(得分:1)
似乎iOS正在释放您的MPMoviePlayerViewController
对象,然后稍后向其发送消息。我建议让实例成为你的类的成员,然后为它实例化一个属性,例如:
@property (nonatomic, retain) MPMoviePlayerViewController *moviePlayerViewController;
...以及相应的@synthesize
声明您的类的实现文件。在分配对象时,您应该执行:
self.moviePlayerController = [[[MPMoviePlayerViewController alloc] initWithContentURL:@"yourUrl"] autorelease];
最后,通过在nil
方法中将对象设置为dealloc
来释放该对象。