简体   繁体   English

滚动到UITableView框架之外

[英]Scroll outside of UITableView frame

How to scroll whole UITableView content outside of UITableView frame? 如何在UITableView框架之外滚动整个UITableView内容? Setting table.scrollIndicatorInsets does not let to scroll upwards and content disappear behind another view at the top. 设置table.scrollIndicatorInsets不允许向上滚动,内容消失在顶部的另一个视图后面。

Try this : 尝试这个 :

after loading of the view completed eg after viewDidAppear: 加载视图后,例如在viewDidAppear之后:

CGFloat oldContentHeight = tableView.contentSize.height;
tableView.contentSize = CGSizeMake(tableView.contentSize.width, oldContentHeight + tableView.bounds.size.height);

Updated the answer. 更新了答案。

As @Tushar pointed out setting the size of view might be the correct approach here, but double the size of the contentview, might be a bit overkill if you have a really long tableview. 正如@Tushar所指出的那样设置视图的大小可能是正确的方法,但是如果你有一个非常长的tableview,那么内容视图的大小加倍可能有点过分。 I would suggest adding the size of the current window instead. 我建议添加当前窗口的大小。

CGFloat oldContentHeight = tableView.contentSize.height;
CGFloat windowHeight = [[[UIApplication sharedApplication] delegate] window].frame.size.height);
tableView.contentSize = CGSizeMake(tableView.contentSize.width, oldContentHeight + windowHeight);

select Table view-> got to Attribute indicator -> tick on "Clip To Bounds". 选择Table view-> got to Attribute indicator - >勾选“Clip To Bounds”。 Done 完成

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM