UITableView showing more rows than specified in numberOfRowsInSection:

后端 未结 9 1088
谎友^
谎友^ 2021-02-01 03:32

I want my tableView to show 6 rows with text in it, in this case \"Example.\" As far as I can tell, I have my numberOfSectionsInTableView: and numberOfRowsIn

相关标签:
9条回答
  • 2021-02-01 03:55

    It's a lot easier to:

    1. return numberOfSections + 1
    2. return 0 rows in the final section

    This keeps it simple!

    0 讨论(0)
  • 2021-02-01 03:57

    The generally accepted way of doing this is to add a footer view with a frame size of CGRectZero, as such:

    [tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]]
    

    What this does is tell the table that there is a footer, and so it stops displaying separator lines. However, since the footer has a CGRectZero as its frame, nothing gets displayed, and so the visual effect is that the separators simply stop.

    0 讨论(0)
  • 2021-02-01 03:57

    Short and simple answer..

    self.tableView.tableFooterView = [UIView new];
    
    0 讨论(0)
提交回复
热议问题