Fixed header to UITableview?

前端 未结 5 792
日久生厌
日久生厌 2020-12-01 09:46

I\'ve got a UITableView that I\'d like to stick a 44px subview on top of. I tried tableViewHeader, but that scrolls with the rest of the table.

5条回答
  •  执念已碎
    2020-12-01 10:05

    I finally figured this out right after posting. Figures. :)

    Here's what I did, in case others run into the same problem:

    1. Delete the existing UITableViewController and its XIB. They're junk. Get really mad while you do.

    2. Make a new UIViewController subclass with a XIB

    3. Open XIB in IB and add your header stuff and a UITableView to the UIView

    4. In the IB Outlets for UITableView make sure you connect Delegate and DataSource to your File Owner

    5. In the header for your view controller, be sure to add to implement these protocols

    6. Implement all the regular UITableView delegate and data source methods you know and love, but in your UIViewController instead of the way you're used to doing it through UITableViewController

    After this things should work.

提交回复
热议问题