Uitableview Not Visible the Last Cell When Scroll Down

UITableview not visible the last cell when scroll down

Use -

  tableView.contentInset = UIEdgeInsetsMake(0, 0, 120, 0); //values

passed are - top, left, bottom, right

Pass bottom offset as per your needs.

How to determine if the last cell of a UITableView is visible on the screen

I just created a project for you to show you one possible solution (there are many).

Basically you just need to get the last cell position, using

guard let lastCell = tableView.cellForRow(at: IndexPath(row: tableView.numberOfRows(inSection: 0)-1, section: 0)) else {
return
}

let lastCellBottomY = lastCell.frame.maxY

Then knowing the tableView height, you can easily calculate the distance between the last cell and the bottom of the screen:

let delta = tableHeight - lastCellBottomY

And check if this distance is enough for you to show or not the fixed button:

if delta > 55 { 
// ...show button
} else {
// ...hide button
}

For the dynamic button (the one you want to add below the last cell of the tableView when user scrolls), you could just add a new section with a custom cell to represent your button.

You can check out the whole idea via this link :

https://www.dropbox.com/s/7wpwv6737efnt5v/ButtonTable.zip?dl=0

Let me know if you have any questions :)

iOS - UITableView Does Not Scroll To Last Row In Data Source

I've determined that this issue has to do with cell height. By increasing tableView.estimatedRowHeight to 44.0, the table view scrolls flawlessly to the bottom. However, there remains an issue with when messages wrap beyond 1 line in a given cell. For each message longer than 1 line, the table scroll comes up a few more pixels short. Removing tableView.estimatedRowHeight altogether seems to result in similar behavior as setting it to say, 44.0. I want to say my original question is answered, but I'm still not sure how to make it scroll perfectly given the likelihood of multi-line cells.

EDIT - SOLUTION

The problem of incorrect scrolling is in fact solved by removing UITableViewAutomaticDimension and manually calculating the height in heightForRowAtIndexPath.

Showing the last cell of Tableview

try use this

DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [tableView] in
if myArray.count > 0 {
tableView.scrollToRow(at: IndexPath(item:myArray.count - 1 , section: 0), at: .bottom, animated: false)
}
}

Last cell in tableview not fully displayed

aianLee,

Set the TableView height in LeveyPopListView properly. It seems that the tableView height is greater than the parent view's height, hence your cell inside the LeveyPopListView's tableview is not positioning in the visible area. Logically the cell is in the bounds of tableView, hence the system is not brining it up. Change the tableView height.

iOS 8 Auto cell height - Can't scroll to last row

Update: Jun 24, 2015

Apple has addressed most of these bugs as of the iOS 9.0 SDK. All of the issues are fixed as of iOS 9 beta 2, including scrolling to the top & bottom of the table view without animation, and calling reloadData while scrolled in the middle of the table view.

Here are the remaining issues that have not been fixed yet:

  1. When using a large estimated row height, scrolling to the last row with animation causes the table view cells to disappear.
  2. When using a small estimated row height, scrolling to the last row with animation causes the table view to finish scrolling too early, leaving some cells below the visible area (and the last row still offscreen).

A new bug report (rdar://21539211) has been filed for these issues relating to scrolling with animation.

Original Answer

This is an Apple bug with the table view row height estimation, and it has existed since this functionality first was introduced in iOS 7. I have worked directly with Apple UIKit engineers and developer evangelists on this issue -- they have acknowledged that it is a bug, but do not have any reliable workaround (short of disabling row height estimation), and did not seem particularly interested in fixing it.

Note that the bug manifests itself in other ways, such as disappearing table view cells when you call reloadData while scrolled partially or fully down (e.g. contentOffset.y is significantly greater than 0).

Clearly, with iOS 8 self sizing cells, row height estimation is critically important, so Apple really needs to address this ASAP.

I filed this issue back on Oct 21 2013 as Radar #15283329. Please do file duplicate bug reports so that Apple prioritizes a fix.

You can attach this simple sample project to demonstrate the issue. It is based directly on Apple's own sample code.

Last cell Not Showing Properly in Tableview

Try to set contentInset

 tableView.contentInset = UIEdgeInsetsMake(0, 0, 110, 0); values are - top, left, bottom, right // change as per your needs

OR

- (void)viewDidLayoutSubviews {
CGFloat navbarHeight = 44; // this is supposed to be 64 but you should dynamically calculate it or better use constraints
CGRect tempFrame = self.view.frame;
self.tableView.frame = CGRectMake(tempFrame.origin.x, tempFrame.origin.y, tempFrame.size.width, tempFrame.size.height - navbarHeight);
}

UITableView scrolling to last cell only displays half of the cell

Turned out to be a timing issue. The tableview hadn't fully rendered yet when I called that method from viewdidload (contentsize of 0). Calling this method in viewDidAppear works brilliantly though.



Related Topics



Leave a reply



Submit