如何滚动到UITabelView的底部(bottom)

来源:互联网 发布:键盘弹钢琴软件下载 编辑:程序博客网 时间:2024/05/02 02:45
面对不同的需求使用不同的方(zi)式(shi)
1.在获取不到tableView准确的属性和数据源的时候
//在viewWillAppear:方法中调用有效(tableView没有确定contentOffset之前调用才会生效)[_tableView  setContentOffset:CGPointMake(0, CGFLOAT_MAX)];

2.在可以获取到tableView准确属性,但不清楚数据源的情况下(数据源可有可无)
//在viewDidAppear:方法中调用有效(tableView已经显示之后才会生效)if (_tableView.contentSize.height > _tableView.frame.size.height) {    self.view.userInteractionEnabled = NO;    CGPoint offset = CGPointMake(0, _tableView.contentSize.height - _tableView.frame.size.height);    [_tableView setContentOffset:offset animated:YES];}

3.在可以获取到tableView准确属性和数据源的情况下
//在可以获得tableView正确属性的任何地方都可以调用此方法将tableView滚动到底部[_tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:lastRow inSection:lastSection] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
0 0
原创粉丝点击