如何让 UITableView 的整个单元格响应点击? [英] How do I make the whole cell of a UITableView respond to taps?

查看:25
本文介绍了如何让 UITableView 的整个单元格响应点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的视图控制器的样子:

This is what my view controller looks like:

当我运行应用程序时,只有小信息图标会响应点击.单元格中任何其他位置的点击将被忽略.如何使整个单元格可点击?

我什至不希望信息图标出现在那里,但这是我目前可以进入详细信息视图的唯一方法......如果我将单元格的附件设置更改为无"以摆脱信息/Detail Disclosure"图标,则单元格根本不会响应点击.

When I run the app, only the little info icon will respond to taps. Taps anywhere else in the cell are ignored. How do I make the whole cell clickable?

I don't even want the info icon to be there, but it's the only way I can get to the detail view, currently... If I change the Accessory setting of the cell to "None" to get rid of the info/"Detail Disclosure" icon, then the cell won't respond to taps at all.


感谢您到目前为止的回复.为了回答您的一些问题,我确实有一个 cellForRowAtIndexPath 方法,它正在被调用.但是,我也使用序列将我的单元格连接到下一个控制器,但是 prepareForSeque:sender 方法仅在我点击信息图标时调用,而不是在我点击单元格时调用...


Thanks for your responses so far. In response to some of your questions, I do have a cellForRowAtIndexPath method, and it is getting called. However, I am also using a seque to connect my cell to the next controller, but the prepareForSeque:sender method only gets called if/when I tap on the info icon, not when I tap on the cell...

我目前正试图弄清楚为什么当我点击单元格时没有调用 prepareForSeque 方法(就像我过去使用表格视图时那样)...

I'm currently trying to figure out why the prepareForSeque method isn't getting called when I tap on the cell (like it has when I've used table views in the past)...

我看过 prepareForSeque 不会触发(如 iMani 所建议的),但我务必为我的手机设置一个标识符.

I've looked at prepareForSeque doesn't fire (as suggested by iMani), but I DO have an identifier for my cell.

我还查看了 PrepareForSeque not called/fired,其中谈到了手动调用 performSegueWithIdentifier:发件人.但是,我过去在使用表格视图时从来不需要手动调用它,而且我过去的单元格仍然触发了 prepareForSeque 方法...

I also looked at PrepareForSeque not called/fired, which talks about manually calling performSegueWithIdentifier:sender. However, I've never had to manually call that in the past when I've used table views, and my cells in the past have still triggered the prepareForSeque method...

推荐答案

问题是我创建了错误类型的序列.这个问题的修复 还修复了我在这里看到的行为.

The issue was that I had created the wrong type of seque. The fix for this question also fixes the behavior I was seeing here.

这篇关于如何让 UITableView 的整个单元格响应点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆