/ Published in: Objective C
URL: http://stackoverflow.com/questions/413055/setting-scroll-position-in-uitableview
Expand |
Embed | Plain Text
// Note: Member variables dataHasChanged and scrollToLast have been // set to YES somewhere else, e.g. when tapping 'Save' in the new-item view. - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; if (dataHasChanged) { self.dataHasChanged = NO; [[self tableView] reloadData]; } else { self.scrollToLast = NO; // No reload -> no need to scroll! } } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; if (scrollToLast) { NSIndexPath *scrollIndexPath = [NSIndexPath indexPathForRow:([dataController count] - 1) inSection:0]; [[self tableView] scrollToRowAtIndexPath:scrollIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES]; } }
You need to login to post a comment.
