首页 > 其他 > 详细

contentOffset、contentSize和contentInset

时间:2016-02-20 21:27:40      阅读:200      评论:0      收藏:0      [点我收藏+]

1、UIScrollView
@property(nonatomic)CGPoint contentOffset;
这个属性用来表示UIScrollView滚动的位置

@property(nonatomic)CGSize contentSize;
这个属性用来表示UIScrollView内容的尺寸,滚动范围(能滚多远)

@property(nonatomic)UIEdgeInsets contentInset;
这个属性能够在UIScrollView的4周增加额外的滚动区域

技术分享

2、UITableView
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.

例如你在delegate方法

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{
    return 100;
}

那么你的tabelview的contentsize就是(320, 4400)

 

contentOffset、contentSize和contentInset

原文:http://www.cnblogs.com/liuzhi20101016/p/5203909.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!