gpt4 book ai didi

ios - Collection View 由于某种原因崩溃

转载 作者:行者123 更新时间:2023-11-29 01:55:08 26 4
gpt4 key购买 nike

    //collection view
UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc] init];
self.collectionView=[[UICollectionView alloc] initWithFrame:self.view.frame collectionViewLayout:layout];
[self.collectionView setDataSource:self];
[self.collectionView setDelegate:self];

[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellIdentifier"];
[self.collectionView setBackgroundColor:[UIColor redColor]];

[self.view addSubview:self.collectionView];

}



- (NSInteger)collectionView:(UICollectionView *)tcollectionView numberOfItemsInSection:(NSInteger)section
{
return 15;
}


// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath];

cell.backgroundColor=[UIColor greenColor];
return cell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return CGSizeMake(50, 50);
}

崩溃:

 -[NSISUnrestrictedVariable collectionView:numberOfItemsInSection:]: unrecognized selector sent to instance 0x7fce804111b0

那是什么?(collection view在view controller里面,他在scrollview里面)

最佳答案

看起来您的 UICollectionView 已从内存中释放,但您仍在尝试访问它。

启用NSZombies,您将看到调用释放内存的位置并相应地修复代码。

关于ios - Collection View 由于某种原因崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30952509/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com