Scrollable all the way UITableView

心已入冬 提交于 2019-12-11 19:27:54

问题


I have this code linked to a button on a ViewController with a UITableView as subview:

-(IBAction)Action:(id)sender{


  [tableView setContentSize:CGSizeMake(320, 1000)];

}

This makes tha tableView scrollable to the bottom so that I can use a couple of buttons I programatically added to the bottom. So far so good.

However, I want the tableView to be ok from the beginning, so I added the code inside viewDidLoad. Surprisingly, it doesn't work at all.

Could somebody give me a hand?

thanks!


回答1:


If your datasource methods are being fired after viewDidLoad, the tableView content size will be reset when it's loaded. You'll need to make sure you've called reloadData for the table before the code above. If you're using a UITableViewController, the order the methods are called is:

viewDidLoad
ViewWillAppear:
<your datasource methods>
ViewDidAppear:

However, if you want buttons at the end of table, you should put them in the tableFooterView. You can do this in interface builder easily by dragging a view to the bottom of the tableView. Or you can do it in code (in your viewDidLoad method, for example)

Per @Justin's answer... your question isn't very clear




回答2:


I'm not sure what your trying to accomplish. If your trying to access button on the bottom of a tableView why not use a Tableview Footer.

And if your trying to just scroll to the bottom of the tableview there is a method for that as well.

Need more info



来源:https://stackoverflow.com/questions/8301560/scrollable-all-the-way-uitableview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!