我正在尝试在imageView
, 内添加点击手势tableView cell
。问题是,如果我将手势代码放在 中cellForRow
,它无法识别 url,当然所有图像都会获取最后一个单元格的 url。如果我将手势代码放在 中didSelect
,则 url 总是为空,我认为是因为手势在单元格获取数据之前就起作用了。
imageView 应该根据其 url 打开一个视频文件,该文件从 XML 解析器获取它。
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];
}