源碼HTKDynamicResizingCell,HTKDynamicResizingCell提供自動計算尺寸的TableViewCell/CollectionViewCel,只要設置了合適AutoLayout的約束。
<ignore_js_op>
使用方法:
使用CocoaPods添加:
pod 'HTKDynamicResizingCell', '~> 0.0.1'
pod install
或者直接將demo中的HTKDynamicResizingCell文件夾添加到自己的項目中。
用法基本和cell一樣:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
// Get cell
HTKSampleCollectionViewCell *cell = (HTKSampleCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:HTKSampleCollectionViewCellIdentifier forIndexPath:indexPath];
// Load data
NSDictionary *dataDict = self.dataArray[indexPath.row];
// Sample image
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"pic%i", arc4random_uniform(10) + 1]];
[cell setupCellWithData:dataDict andImage:image];
return cell;
}
詳細的請參考demo中兩個Sample VC的具體寫法。
詳細說明:http://ios.662p.com/thread-2270-1-1.html
新聞熱點
疑難解答