0

In my app I have used a UITableViewControllersub class to display a list of data. I finished every thing in the project, but the client needs the top row of the table to stay on top and not scroll with the rest of the content. I know this could easily be achieved using a UIViewController instead of a UITableViewController but would like to avoid this. I'm here for a final attempt to see if there is any way to fix some rows in a table view.

Please note that there are 4 different UITableViewController's in my project and they all have some complex logic in their table view delegate methods. This means a lot of work if I need to change all the UITableViewControllers into UIViewControllers. Anyone have any ideas?

T. Benjamin Larsen
  • 6,373
  • 4
  • 22
  • 32
Blios
  • 719
  • 1
  • 16
  • 30

4 Answers4

2

I have two suggestions for you:

  1. More common practice is to use property of the UITableView

    @property(nonatomic, retain) UIView *tableHeaderView
    
  2. Second way to place your table view as child view and add another subview

    • UIView
      • HEADER UIView
      • UITableView
Darshan Kunjadiya
  • 3,323
  • 1
  • 29
  • 31
skyylex
  • 855
  • 1
  • 10
  • 24
1

All you need to do is to implement method (declared in UITableViewDelegate):

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return self.yourHeaderTopView;
}
Szu
  • 2,254
  • 1
  • 21
  • 37
0

You need to create the custom tableheaderview. For more refer this

Community
  • 1
  • 1
Hussain Shabbir
  • 14,801
  • 5
  • 40
  • 56
0

Add 2 cells use first as static and fill up the information as u want. set the Reuse modifier of the second and call that second cell in the cellAtRowForIndexPath method to use that second cell continuously

Saheb Roy
  • 5,899
  • 3
  • 23
  • 35