undefinedfix
Sign in

I slide a tableview to the bottom, but it always doesn't slide to the bottom. There will be a small section that doesn't slide down

russ5811 edited in Sun, 11 Oct 2020

1. If you want to make a conversation interface, slide to the bottom when you come in. 2, but after using the code that slides to the bottom, it doesn't slide to the bottom. It's always a short distance away. 3. It's not that there is a section at the bottom that can't slide up. It can slide up. That is, when you come in to this view, you can't directly slide to the bottom 4. This is my code

 let indexPath = NSIndexPath(forRow: self.chatMessageModel.contentType.count-1, inSection: 0)
 self.scrollToRowAtIndexPath(indexPath, atScrollPosition: .Bottom, animated: false)
 

5. This picture is what I look like after entering the conversation view

6. The red box in this picture shows that there is a small section below the tableview that has not been slid to the bottom

Q: who knows why?

14 Replies
oocri
commented on Sun, 11 Oct 2020

Does the input field below cover the content below? Try setting contentoffset or contentinset.

enfau
commented on Sun, 11 Oct 2020

Is the row of indexpath wrong?

suxbr
commented on Sun, 11 Oct 2020

Do you want to set the property automatically adjust scrollviewinsets? It doesn't look like 64

javhottubeqd
commented on Mon, 12 Oct 2020
  1. Make sure tableview frame is OK
  2. Make sure that the tableview reload is complete
  3. Try scroll to contentoffset (max, max)
koljoxen
commented on Mon, 12 Oct 2020
[tableView setContentOffset:CGPointMake(CGFLOAT_MAX, CGFLOAT_MAX)];

This allows tableview to directly display the following OC code. Swift can find the same method. I guess so

tableview.ContentOffset = ·······
3r1k
commented on Mon, 12 Oct 2020
  1. You can reset the tableview frame in viewwill appearance; you can print "tableview frame" here
  2. And see if the height of the line is right.
  3. If not, set contentoffset
Geeroc
commented on Mon, 12 Oct 2020
[tableView setContentOffset:CGPointMake(CGFLOAT_MAX, CGFLOAT_MAX)];
Warrior_76
commented on Mon, 12 Oct 2020

Has the problem been solved? I have the same problem. I don't know how to solve it

MarkusEgle
commented on Mon, 12 Oct 2020

Have you solved it as like as two peas?

jesse_b
commented on Tue, 13 Oct 2020

Write your code in the - (void) viewdidappearance: (bool) animated {} method

coderina
commented on Tue, 13 Oct 2020

It can be solved in the following ways, which is how I solved it.

//tableView还没刷新完就开始调用滚到到底部的方法,所以可以利用伪延迟来进行处理。
double delayInSeconds = 0.1;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){

    if ([self.chatModel.dataSource count] > 1){
        // 动画之前先滚动到倒数第二个消息
        [self.chatTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[self.chatModel.dataSource count] - 2 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:NO];
    }
    //self.chatTableView.hidden = NO;
    NSIndexPath* path = [NSIndexPath indexPathForRow:[self.chatModel.dataSource count] - 1 inSection:0];
    [self.chatTableView scrollToRowAtIndexPath:path atScrollPosition:UITableViewScrollPositionBottom animated:YES];
});
--------------------------
参考:https://stackoverflow.com/questions/21371351/uitableview-not-scrolling-to-bottom
https://stackoverflow.com/questions/25686490/ios-8-auto-cell-height-cant-scroll-to-last-row
ijsdm
commented on Tue, 13 Oct 2020

How is this problem solved

NWMFRWindsor
commented on Tue, 13 Oct 2020

Have you solved this problem? Can you leave a QQ. Let me ask you something. I have the same problem

JayB
commented on Wed, 14 Oct 2020

I also met the same problem. How did you solve it

lock This question has been locked and the reply function has been disabled.