22子类化UIScrollView实现对Cell的布局
@interface DZTableView : UIScrollViewtypedef map<int, float> DZCellYoffsetMap;
typedef vector<float> DZCellHeightVector;
.....
DZCellHeightVector _cellHeights;
DZCellYoffsetMap _cellYOffsets;- (CGRect) _rectForCellAtRow:(int)rowIndex
{
if (rowIndex < 0 || rowIndex >= _numberOfCells) {
return CGRectZero;
}
float cellYoffSet = _cellYOffsets.at(rowIndex);
float cellHeight = _cellHeights.at(rowIndex);
return CGRectMake(0, cellYoffSet - cellHeight, CGRectGetWidth(self.frame), cellHeight);
}Last updated