imageView
内のにタップジェスチャを追加しようとしていtableView cell
ます。問題は、ジェスチャ コードを に入れるとcellForRow
、URL が認識されず、もちろんすべての画像が最後のセルの URL を取得することです。ジェスチャ コードを に入れるとdidSelect
、URL は常に null になります。これは、セルがデータを取得する前にジェスチャが機能しているためだと思います。
imageView は、XML パーサーから取得した URL に基づいてビデオ ファイルを開く必要があります。
selectedArticle = [self getArticleAtIndex:indexPath];
UIImageView* imageTap = [
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(actionHandleTapOnImageView)];
[singleTap setNumberOfTapsRequired:1];
imageTap.userInteractionEnabled = YES;
[imageTap addGestureRecognizer:singleTap]
(void)actionHandleTapOnImageView{
NSString *path = selectedArticle.videoUrl;
NSURL *videoURL = [NSURL URLWithString:path];
MPMoviePlayerViewController *theArticle = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL];
[self presentMoviePlayerViewControllerAnimated:theArticle];
theArticle.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[theArticle.moviePlayer play];
}