How to Start UITableView on the Last Cell?

前端 未结 8 1267
囚心锁ツ
囚心锁ツ 2020-11-30 01:43

In Apple\'s Messages app, when you click a correspondent\'s name and switch to the table view of the conversation (with balloons for each message), the table appears scrolle

8条回答
  •  孤独总比滥情好
    2020-11-30 02:31

    Following DyingCactus's reply above, I added this method to my controller:

    -(void)viewWillAppear:(BOOL)animated {
          [self.tableView reloadData];    
          NSIndexPath* ip = [NSIndexPath indexPathForRow:[self.tableView numberOfRowsInSection:0] - 1 inSection:0];
          [self.tableView scrollToRowAtIndexPath:ip atScrollPosition:UITableViewScrollPositionTop animated:NO];
    }
    

    And now it works, exactly what I wanted. Thanks!

提交回复
热议问题