iOS-UITableView 滚动到底部的方法

1.

- (void)scrollsToBottomAnimated:(BOOL)animated

{

    [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:self.dataArr.count-1 inSection:0atScrollPosition:UITableViewScrollPositionBottom animated:NO];//这里一定要设置为NO,动画可能会影响到scrollerView,导致增加数据源之后,tableView到处乱跳

}


2.

- (void)scrollViewToBottom:(BOOL)animated

{

    if (self.tableView.contentSize.height > self.tableView.frame.size.height)

    {

        CGPoint offset = CGPointMake(0, self.tableView.contentSize.height - self.tableView.frame.size.height);

        [self.tableView setContentOffset:offset animated:animated];

    }

}

你可能感兴趣的:(iOS,随手记)