UITableView问题

iOS 码拜 9年前 (2015-05-07) 607次浏览 0个评论
 

怎样判断tableview是否滚动到底部?

100分
3 down vote

in the tableview delegate do something like this

– (void)scrollViewDidScroll:(UIScrollView *)aScrollView {
    CGPoint offset = aScrollView.contentOffset;
    CGRect bounds = aScrollView.bounds;
    CGSize size = aScrollView.contentSize;
    UIEdgeInsets inset = aScrollView.contentInset;
    float y = offset.y + bounds.size.height – inset.bottom;
    float h = size.height;
    // NSLog(@”offset: %f”, offset.y);   
    // NSLog(@”content.height: %f”, size.height);   
    // NSLog(@”bounds.height: %f”, bounds.size.height);   
    // NSLog(@”inset.top: %f”, inset.top);   
    // NSLog(@”inset.bottom: %f”, inset.bottom);   
    // NSLog(@”pos: %f of %f”, y, h);

    float reload_distance = 10;
    if(y > h + reload_distance) {
        NSLog(@”load more rows”);
    }
}

UITableView is a subclass of UIScrollView, and UITableViewDelegate conforms to UIScrollViewDelegate. So the delegate you attach to the table view will get events such as scrollViewDidScroll:, and you can call methods such as contentOffset on the table view to find the scroll position.
THX,我试试

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明UITableView问题
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!