1

誰かが同様の問題に遭遇し、もちろん、適切な、またはそれほど適切ではない(しかし機能している)解決策/回避策を見つけたのではないかと思います。

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

そのトピックについて何か考えを持っている人はいますか?

4

1 に答える 1

1

iOSがMPMoviePlayerViewControllerオブジェクトを解放し、後でメッセージを送信しているようです。インスタンスをクラスのメンバーにしてから、そのプロパティをインスタンス化することをお勧めします。例:

@property (nonatomic, retain) MPMoviePlayerViewController *moviePlayerViewController;

...対応する宣言とともに、@synthesizeクラスの実装ファイル。オブジェクトを割り当てるときは、次のことを行う必要があります。

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

最後に、メソッドでオブジェクトをに設定して、オブジェクトを解放しnilますdealloc

于 2010-10-07T13:28:29.573 に答える