开发者

UITableView inside UIScrollView – Table Cell is not selectable

开发者 https://www.devze.com 2023-03-16 07:23 出处:网络
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

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 fi开发者_StackOverflow中文版ll 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!


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消