ios开发scrollView中contentSize、contentInset和contentOffset区别
2015-12-30 18:55
369 查看
ios开发scrollView中contentSize、contentInset和contentOffset区别
contentSize是scrollview可以滚动的区域,比如frame = (0 ,0 ,320 ,480) contentSize = (320 ,960),代表你的scrollview可以上下滚动,滚动区域为frame大小的两倍。contentOffset是scrollview当前显示区域顶点相对于frame顶点的偏移量,比如上个例子你拉到最下面,contentoffset就是(0 ,480),也就是y偏移了480
contentInset是scrollview的contentview的顶点相对于scrollview的位置,例如你的contentInset = (0 ,100),那么你的contentview就是从scrollview的(0 ,100)开始显示
另外UITableView是UIScrollView的子类,它们在上述属性又有所不同,tabelview的contentsize是由它的下列方法共同实现的
- (NSInteger)numberOfSections;
- (NSInteger)numberOfRowsInSection:(NSInteger)section;
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;
它会自动计算所有的高度和来做为它的contentsize的height.
相关文章推荐
- iOS准备程序
- iOS NSUserDefaults 简介,使用 NSUserDefaults 存储自定义对象
- [转]iOS 中字典与json格式的互相转换
- ios应用view之间数据传递的方式
- iOS中switch case语句里面不能定义对象,有语法错误,除非加一个花括号
- iOS_SpriteKit_02_SpriteKit编程指南
- iOS GET方式进行同步请求
- iOS开发:深入理解RunLoop
- IOS开发之----NSDictionary,JSON和XML互相转换
- ios开发初体验
- iOS之新建工程上下出现黑色块
- iOS Autolayout入门简介
- 完美解决!隐藏listview的headerView,实现动态下拉,(仿ios)
- ios 百度地图坐标转换
- iOS 手势集合
- ios 运行时环境的应用
- iOS开发动画(Animation)图片360度不停旋转
- 【iOS】导航、Tabbar、tableview配合使用时,tableview错位的问题
- iOS Autolayout -- scrollview
- iOS9搜索三剑客之NSUserActivity