UIScrollView 内的 UITableView – 表格单元格不可选择 [英] UITableView inside UIScrollView – Table Cell is not selectable
问题描述
就像标题中所说的,我有一个 UITableView
的问题,它在我的应用程序中是一个 UIScrollView
的子视图.在我的 UIScrollview 中,我有几个图像、标签等,并且在底部设置了我的 UITableView.我可以用值等填充表格视图,但是当我尝试通过触摸选择一个单元格时,没有任何反应.要查看 UITableView,您必须在 UIScrollView 中向下滚动一点.也许这是问题?我该如何解决这个问题?
Like said in the title, I have a problem with an UITableView
which is in my app a subview of an UIScrollView
. In my UIScrollview I have several images, labels, etc. and at the bottom my UITableView is set. I can fill the table view with values etc., but when I try to select a cell by touch, nothing happens.
To see the UITableView, you must scroll down a little bit in the UIScrollView. Maybe this is the issue? How do I solve this problem?
谢谢!
推荐答案
当我不得不做这种事情的时候,我习惯把 UITableView
顶部的所有内容放在一个UIView
并将此视图设置为 tableView 的 tableHeaderView
.例如:
When I have to do this kind of thing I use to put all the content that is on the top of the UITableView
in a UIView
and set this view to the tableHeaderView
of the tableView. For example:
UIView * vwHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
// set the content of the header
// ...
_tblView.tableHeaderView = vwHeader;
这样,此标题将成为表格滚动的一部分,您将不需要滚动视图.你可以对 tableFooterView
做同样的事情.
This way, this header will be part of the table scrolling and you won't need a scrollView. You can do the same with the tableFooterView
.
这篇关于UIScrollView 内的 UITableView – 表格单元格不可选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!