iPhone开发:UIScrollView分页算法 [iPhone开发]
post by 朦朧中的罪惡 / 2010-2-22 20:09 Monday
在使用 UIScrollView 分页的时候我们如何确定当前是第几页?
首先需要开启分页设置
scrollView.pagingEnabled = YES;
然后我们在委托的类上实现以下方法
- (void) scrollViewDidScroll:(UIScrollView *)sender {
// 得到每页宽度
CGFloat pageWidth = sender.frame.size.width;
// 根据当前的x坐标和页宽度计算出当前页数
int currentPage = floor((sender.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
}
标签: Objective-c iPhone
« PHP使用Session和全局变量开启时候出现waring提示的分析 | iPhone开发:通过NSURLRequest获得服务器返回的http header和http status»



引用: