search

Home  >  Q&A  >  body text

ios - UITableView无法滚动到底部

UITableView无法滚动到底部

在viewdidload 方法里面

/* 首次出现让tableView滚动到底部 /

[self.messageTable setContentOffset:CGPointMake(CGFLOAT_MAX, CGFLOAT_MAX)];

或者 采用了 scrollToRowAtIndexPath 这个方法 同样不管用。
跪求大神帮忙,再此跪了!!!!

这句话,肯定不会滚动到最后一行,说不准是第几行,打印了tablview 的frame 是对的。并且在这句话之前,也reload 了,不知道咋回事有遇到相同问题的人吗?

我做的是一个聊天界面

并且我发送一条消息例如发送一条自定义消息,使用的是滚动到多少行,也显示半个。。。不知道咋回事 如下图

PHPzPHPz2892 days ago410

reply all(3)I'll reply

  • 迷茫

    迷茫2017-04-18 09:37:59

    Contribute your own answer, dispatch_group_t downloadGroup = dispatch_group_create();

    dispatch_group_enter(downloadGroup);
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        [self refreshTableView];
        dispatch_group_leave(downloadGroup);
    });
    
    dispatch_group_notify(downloadGroup, dispatch_get_main_queue(), ^{
        [self scrollToMessageBottom];
    });

    Force refresh first, then scroll

    reply
    0
  • 阿神

    阿神2017-04-18 09:37:59

    If there is no problem with scrolling, check whether the bottom of your tableView is blocked by the bar at the bottom, and if so, adjust the height.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:37:59

    I used this method in the past and it was often inaccurate. Using scrollToRowAtIndexPath is better than this method

    reply
    0
  • Cancelreply