【发布时间】:2014-03-13 18:43:12
【问题描述】:
我有一个 UITableView,我在其中填充自定义构建的 UITableViewCells。这些有一张图片和一些标签。
有没有什么方法可以在单击图片时执行某种转场,但是当我单击每个标签时,它会执行不同的转场。我只希望在单击 UIImageView 或 UILabels 时执行这些 segues。
我目前正在玩以下想法。
- 在 cellForRowAtIndexPath 中创建 UIImageView 和 UILables 时添加手势识别器
- 上面的触摸手势会触发segue
我的代码在我创建 UITableViewCells 的 UITableView cellForRowAtIndexPath 委托中看起来像这样
cell.myImage.userInteractionEnabled = YES;
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doSomething:)];
singleTap.numberOfTapsRequired = 1;
singleTap.delegate = self;
[cell.myImage addGestureRecognizer:singleTap];
当我单击 UIImageView 时,这会覆盖表视图的 didSelectRowAtIndexPath 委托,因此我尝试从 doSomething: 函数触发 segue,但此函数不知道 UITableView indexPath,因此无法将正确的信息发送到目的地视图控制器(它总是发送 0)。
我确信必须有一个简单的方法来做到这一点
欢迎任何想法。提前致谢。
【问题讨论】:
标签: ios iphone objective-c uitableview