zoukankan      html  css  js  c++  java
  • (转)iPhone 判断UITableView 滚动到底部

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

    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");
    		
    		if(!isLoading)
    			[self loadMore];
    	} 
    }
    

      

  • 相关阅读:
    老了老了呜呜呜呜
    我们的焦点在哪里
    visual studio 2010
    饥饿游戏2 影评
    两个极端
    关于怀旧
    进程 线程 碎角料
    拥塞控制
    [zz] 几种类间关系:继承、实现、依赖、关联、聚合、组合及UML实现图
    Markdown 的使用
  • 原文地址:https://www.cnblogs.com/greywolf/p/3252270.html
Copyright © 2011-2022 走看看