jjzjj

cellForItemAtIndexPath

全部标签

ios - UICollectionView cellForItemAtIndexPath 上的 Swift 专门崩溃

Crashlytics为我提供了以下堆栈跟踪。崩溃发生不一致。发生在所有iOS9设备上,但很少见。无法找出问题的根源。在我拥有的任何设备上都没有发生过,过去3天一直试图崩溃。Crashed:com.apple.main-thread0cherish0x10014ee18specializedPersonalizeViewController.collectionView(UICollectionView,cellForItemAtIndexPath:NSIndexPath)->UICollectionViewCell(PersonalizeViewController.swift:15

ios - Collection View :cellForItemAtIndexPath: why my view has zero subviews?

请考虑以下代码:funccollectionView(collectionView:UICollectionView,cellForItemAtIndexPathindexPath:NSIndexPath)->UICollectionViewCell{letcell=collectionView.dequeueReusableCellWithReuseIdentifier("DataItemCell",forIndexPath:indexPath)asDataItemCollectionViewCellprintln("\(cell.parametersView.subviews.co

ios - cellForItemAtIndexPath 在强制滚动以使其可见后返回 nil

所以我正在尝试编写一些代码,将CollectionView滚动到某个索引,然后提取对单元格的引用并执行一些逻辑。但是我注意到,如果该单元格在滚动之前当前不可见,则cellForItemAtIndexPath调用将返回nil,从而导致我的其余逻辑失败。[_myViewscrollToItemAtIndexPath:[NSIndexPathindexPathForItem:indexinSection:0]atScrollPosition:UICollectionViewScrollPositionTopanimated:NO];//Triedwithandwithoutthisline,

ios - cellForItemAtIndexPath 在强制滚动以使其可见后返回 nil

所以我正在尝试编写一些代码,将CollectionView滚动到某个索引,然后提取对单元格的引用并执行一些逻辑。但是我注意到,如果该单元格在滚动之前当前不可见,则cellForItemAtIndexPath调用将返回nil,从而导致我的其余逻辑失败。[_myViewscrollToItemAtIndexPath:[NSIndexPathindexPathForItem:indexinSection:0]atScrollPosition:UICollectionViewScrollPositionTopanimated:NO];//Triedwithandwithoutthisline,

objective-c - UICollectionView cellForItemAtIndexPath 未注册单元格

我正在尝试使用UICollectionViewCell,因为我只想显示图像。我可以使用UICollectionViewCell的contentView属性上的UIColorcolorWithImage:将图像添加到单元格。在我的loadView方法中,我按如下方式注册单元格:[self.collectionViewregisterClass:[ImageCellclass]forCellWithReuseIdentifier:@"MyCell"];下面是我的cellForItemAtIndexPath方法:-(UICollectionViewCell*)collectionView:(

objective-c - UICollectionView cellForItemAtIndexPath 未注册单元格

我正在尝试使用UICollectionViewCell,因为我只想显示图像。我可以使用UICollectionViewCell的contentView属性上的UIColorcolorWithImage:将图像添加到单元格。在我的loadView方法中,我按如下方式注册单元格:[self.collectionViewregisterClass:[ImageCellclass]forCellWithReuseIdentifier:@"MyCell"];下面是我的cellForItemAtIndexPath方法:-(UICollectionViewCell*)collectionView:(

ios - UICollectionView 选择和取消选择问题

所以我有一个主对象,它有许多与之关联的图像。图像也是对象。假设你有一个CollectionViewController,在那个Controller中你有cellForItemAtIndexPath基于主要对象,如果它有与之关联的当前图像,我想将selected设置为true。但我希望用户能够随时“取消选择”当前单元格以删除它与主要对象的关联。我发现如果您将“selectedtotrue”设置为true-如果cellForItemAtIndexPath中的主要对象和图像之间存在关系,则取消选择不再是一个选项。在didDeselectItemAtIndexPath和didSelectIte

ios - UICollectionView 选择和取消选择问题

所以我有一个主对象,它有许多与之关联的图像。图像也是对象。假设你有一个CollectionViewController,在那个Controller中你有cellForItemAtIndexPath基于主要对象,如果它有与之关联的当前图像,我想将selected设置为true。但我希望用户能够随时“取消选择”当前单元格以删除它与主要对象的关联。我发现如果您将“selectedtotrue”设置为true-如果cellForItemAtIndexPath中的主要对象和图像之间存在关系,则取消选择不再是一个选项。在didDeselectItemAtIndexPath和didSelectIte

ios - 不为 collectionView 调用 cellForItemAtIndexPath

我在Storyboard中采用了UICollectionView。我还设置了datasource和delegate。下面的方法被调用-(NSInteger)collectionView:(UICollectionView*)collectionViewnumberOfItemsInSection:(NSInteger)section{return4;}但是-(UICollectionViewCell*)collectionView:(UICollectionView*)collectionViewcellForItemAtIndexPath:(NSIndexPath*)indexPat

ios - 未调用 UICollectionView cellForItemAtIndexPath 方法

cellForItemAtIndexPath未被调用。我觉得一切都很正常有什么问题?-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView*)collectionView{return1;}-(NSInteger)collectionView:(UICollectionView*)collectionViewnumberOfItemsInSection:(NSInteger)section{return10;}-(UICollectionViewCell*)collectionView:(UICollectionVi