UITableView inside UIScrollView – Table Cell is no

2019-07-10 20:02发布

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?

Thanks!

2条回答
戒情不戒烟
2楼-- · 2019-07-10 20:08

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;

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.

查看更多
老娘就宠你
3楼-- · 2019-07-10 20:19

UITableview is

Inherits from

UIScrollView : UIView : UIResponder : NSObject

So why do you put your tableview inside the hscrollview? Don't do this.

Then unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.

查看更多
登录 后发表回答