Reputation: 203
I use a dynamic tableViewController
. I implement the numberOfSection
to return 4, and the numberOfRowInSection
return 1. These are the only changes I made for the blank TableViewController
. But when I run it on simulator, it shows multiple cells, which I expected to be only four cells. Why is that?
Note: If I change the height of each cell to let the screen only fit four cells at a time, it will work fine since it won't let be me scroll down. So I guess is the tableViewController
always try to fill the screen no matter how many cell it should display?
Upvotes: 0
Views: 34
Reputation: 22651
Yes, the UITableView
will always continue to fill the screen with 'empty' cells of the default row height. To prevent this, you could add the following code in viewDidLoad
:
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
(For Swift, check @VictorSigler's answer.)
Upvotes: 1
Reputation: 23449
In Swift:
self.tableView.tableFooterView = UIView(frame: CGRect.zeroRect)
Upvotes: 0