UITableView sticky footer / custom toolbar implementation

前端 未结 1 519
萌比男神i
萌比男神i 2021-01-26 01:26

I am using a UITableViewController, and what I would like to do is to add a custom toolbar under the UIView.

I have tried enabling the toolbar

1条回答
  •  被撕碎了的回忆
    2021-01-26 01:58

    Instead of subclassing UITableViewController for your implementation, you might find it easier to subclass a plain UIViewController and add a UITableView to it. This would give you more flexibility in terms of customizing the layout.

    Basically the steps would be:

    1. Have your class inherit from UIViewController (instead of UITableViewController)
    2. Have your class implement the UITableViewDelegate and UITableViewDataSource protocols
    3. Implement the UITableViewDelegate and UITableViewDataSource methods in your class (e.g. cellForRowAtIndexPath:, didSelectRowAtIndexPath:, etc)
    4. In IB, add a UITableView as a subview to your view controller's view
    5. Set the delegate and datasource properties of the table view you just added to be your viewcontroller class
    6. Resize the frame of the UITableView to allow space at the bottom for your inputField and button

    This way you can add the inputField and button to your viewController's view (at the bottom) and they won't scroll because they are separate from the tableview.

    0 讨论(0)
提交回复
热议问题