Ich habe einen Chat-Bildschirm mit UITableView
gebaut. Ich möchte bis zum Ende von UITableView
scrollen, der Moment, in dem der Bildschirm von einem anderen View-Controller geöffnet wird. Mit trivial scroll to bottom Funktionen, zeigt einen Ruck, wenn der Chat lang ist. Gibt es eine Alternative?Scrollen Sie nach unten in UITableView
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
dispatch_async(dispatch_get_main_queue(), ^{
NSIndexPath* lastIndexPath = [NSIndexPath indexPathForRow:_messagesArray.count-1 inSection:0];
[_tableView scrollToRowAtIndexPath:lastIndexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
});
}
Verwendung setContentOffset statt –