iOS UItableview scrollToRowAtIndexPath not working anymore

前端 未结 9 560
不知归路
不知归路 2020-12-30 01:14

This morning I just installed new Xcode which includes iOS 6.

I have a table view loaded with a plist file containing chapters and lines. Chapters define the section

9条回答
  •  隐瞒了意图╮
    2020-12-30 01:44

    It worked for me in ios11

    self.tableView.estimatedRowHeight = 0;
    self.tableView.estimatedSectionFooterHeight = 0;
    self.tableView.estimatedSectionHeaderHeight = 0
    
    dispatch_async(dispatch_get_main_queue(), ^{
       NSInteger numberOfSections = self.tableView.numberOfSections;
       if (numberOfSections > 0)
       {
         NSInteger lastSection = numberOfSections - 1;
         NSInteger lastRowInLastSections = [self.tableView numberOfRowsInSection:lastSection] - 1;
    
         NSIndexPath *indexPath = [NSIndexPath indexPathForRow:lastRowInLastSections inSection:lastSection];
         [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:isAnimated];
    }
    });
    

提交回复
热议问题