Reputation: 57
My UITableView does not scroll to the bottom and stops before all the content can be displayed (cuts off the last few rows). I have checked that my UITableView is equal to the screen size, but the content size is greater than screen and table height. I am not sure why this is happening.
Upvotes: 4
Views: 9991
Reputation: 59
Unchecking "Under Bottom Bars" of respective ViewController from storyboard inside attribute inspector solved my issue.
Upvotes: 0
Reputation: 1214
In my case...removing
tableview.frame.size = tableview.contentsize worked
Upvotes: 0
Reputation: 8289
1) Do you have a UITabBar
at the bottom of your screen? This content may be covered by the bar. IF so, go your storyboard and to your UIViewController
you have the UITableView
placed in and uncheck it's Under Bottom Bars
boolean.
2) You might have an NSLayoutConstraint
set at the bottom that is to the negative. Meaning your UITableView
will be extending to the bottom of the screen. IF so, reset your UITableView
's bottom constraint to 0.0.
3) You might want to try using UITableView
scroll method. Get the index of the last cell:
[yourTableView scrollToRowAtIndexPath:lastCellIndex
atScrollPosition:UITableViewScrollPositionTop
animated:YES];
4) UITableView
is subclassed from UIScrollView
. Therefore you can treat it as such.
If ever cell in the UITableView
has the same height, you can multiple the number of objects in your datasource times the height of the cell, then you know what value to enter into your UIScrollView/TableView
method as contentOffset:
(void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
Upvotes: 4
Reputation: 15035
May be you need to set the automatic dimensions:-
You can pinned your tableView to the superview with the correct constraint and if you are using the custom tableview cell then pinned all the labels constraint (leading, trailing, top and bottom)to the cell and then inside your ViewController viewDidLoad
method write the below code:-
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 44.0
Once your constraints are correct then your table view cell content size will resize dynamically depends on the content.
Note:-
Do not use the tableview delegate method(heightForRowAtIndexPath)
to adjust the height if you are using UITableViewAutomaticDimension
Upvotes: 2
Reputation: 24195
That most probably happen in small iPhone devices. because you didnt set your bottom constraint of the tableview correctly. Check that constraint. if it doesnt exist add it.
Upvotes: 2