Ios 自定义集合视图单元格

Ios 自定义集合视图单元格,ios,uicollectionview,uicollectionviewcell,Ios,Uicollectionview,Uicollectionviewcell,我用这段代码创建了定制的CollectionViewCell,然后使用它。为什么? - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.webView = [[UIWebView alloc] initWithFrame:CGRectZero]; _webView.scalesPageToFit = YES; _webView.allows

我用这段代码创建了定制的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];

因为您在初始化中分配了一个webview,所以我猜这就是为什么您会看到延迟

UIWebView
需要进行大量分配,由于它位于自定义单元格中,因此可能会被多次调用。看到我要去哪里了吗


正如我在评论中所说,如果没有一些结果,很难真正了解应用程序内部的情况。

您应该了解。很抱歉,找不到该页面。