我使用该代码创建自定义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;
如果我使用这个代码都可以
- (CollectionCell *)collectionView:(IndexedCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
cell.imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
cell.imageView.clipsToBounds = YES;
[cell.contentView addSubview:cell.imageView];
1 回答
由于您在初始化中分配了一个webview,我猜这就是你看到滞后的原因 .
UIWebView
是一个繁重的分配,因为它可能会被多次调用's within a custom cell, it' . 看看我要去哪里?正如我在评论中所述,它在您的应用程序内部没有Time Profiler的结果 .