我使用該代碼創建了自定義的CollectionViewCell,並有滯後的情況,然後我使用它。爲什麼?Custom CollectionViewCell
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
self.webView = [[UIWebView alloc] initWithFrame:CGRectZero];
_webView.scalesPageToFit = YES;
_webView.allowsInlineMediaPlayback = YES;
_webView.mediaPlaybackRequiresUserAction = NO;
_webView.scrollView.scrollEnabled = NO;
_webView.scrollView.bounces = NO;
[self.contentView addSubview:self.webView];
self.imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
self.imageView.clipsToBounds = YES;
[self.contentView addSubview:self.imageView];
}
return self;
如果我使用此代碼一切OK
- (CollectionCell *)collectionView:(IndexedCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
cell.imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
cell.imageView.clipsToBounds = YES;
[cell.contentView addSubview:cell.imageView];
您應該瞭解[時間分析器](https://developer.apple.com/videos/wwdc/2014/?include=418#418)。 – jakenberg