UICollectionView不重用单元格 [英] UICollectionView do not reuse cells

查看:152
本文介绍了UICollectionView不重用单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iOS 7上遇到重用单元和 UICollectionView 时遇到问题。我的代码在iOS 6上正常工作,但在iOS 7中,它不会在调用 dequeueReusableCellWithReuseIdentifier (不要调用 prepareForReuse )。



https:/ /developer.apple.com/library/ios/samplecode/CollectionView-Simple/Introduction/Intro.html#//apple_ref/doc/uid/DTS40012860 不会在iOS7上重复使用单元格(但在iOS6上运行良好),在每个 dequeueReusableCellWithReuseIdentifier 它创建一个新的单元格并释放旧的单元格。是否有一些新的东西阻止细胞重复使用?



我的细胞足够大,它们是非常低效的,不能重复使用它们。我已经注意到在iOS 7,但不是在iOS 6,因为他们没有被重用在iOS 7。

解决方案

更新2:

原来,这个答案不正确。
请参阅下面的答案或点击此链接 http://stackoverflow.com/a/20147799/814389



p>因此,我已经找到了更多关于这个 的错误。



我抓住了所有的设备对我有用,并对每一个进行相同的测试,这些是结果:

 设备操作系统版本CELL REUSE 
============= ============= =============
iPad 4 7.0.0 YES
iPad 4 7.0.3是
iPad 3 7.0.3无
iPad 2 7.0.3无
iPad Mini 7.0.0是
iPad Mini 7.0.3是
iPhone 5s 7.0.3是
iPhone 4 7.0.2是
iPhone 4 7.0.3是

正如你所看到的,看起来像是因为某些原因,细胞重用在旧的iPad(不能渲染模糊的那些)上不起作用。



我最初认为,苹果可能刚刚阻止重用在旧iPad上,由于某种性能问题,但如果这是有意义的,iPhone 4也将显示相同的结果。



为了解决我的应用程序中的这个问题,我有一个NSMutableDictionary在我的collectionViewController和我存储我的单元格在其中key是indexPath ..在我的情况下,这是OK的,因为我只有大约9个单元格,它们的indexPath永远不会改变,但如果你需要更灵活的那么也许这是一个好主意checkout PSTCollectionView( https://github.com/steipete/PSTCollectionView






物理设备..它似乎工作正常在iOS 7和6,但不是iOS 7模拟器!!!



只是把一些日志在collectionView示例:

  @implementation Cell 

- (id)initWithCoder:(NSCoder *)aDecoder
{
NSLog(@%s,__ func__);
self = [super initWithCoder:aDecoder];
if(self)
{
CustomCellBackground * backgroundView = [[CustomCellBackground alloc] initWithFrame:CGRectZero];
self.selectedBackgroundView = backgroundView;
}
return self;
}

- (void)prepareForReuse
{
NSLog(@%s,__ func__);
}

- (void)dealloc
{
NSLog(@%s,__ func__);
}

@end

然后滚动到底部所有三个设备,这是输出:



iOS 7模拟器

  2013-10-09 17:42:45.798 CollViewSmpl [9547:a0b]  -  [Cell initWithCoder:] 
2013-10-09 17:42:45.807 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:45.811 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:45.841 CollViewSmpl [9547: a0b] - [Cell initWithCoder:]
2013-10-09 17:42:45.844 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:45.848 CollViewSmpl [ 9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:45.852 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:45.857 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.080 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42 :47.083 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.181 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17 :42:47.183 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.208 CollViewSmpl [9547:a0b] - [Cell dealloc]
2013-10-09 17:42:47.208 CollViewSmpl [9547:a0b] - [Cell dealloc]
2013-10-09 17:42:47.214 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10- 09 17:42:47.218 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.245 CollViewSmpl [9547:a0b] - [Cell dealloc]
2013-10 -09 17:42:47.246 CollViewSmpl [9547:a0b] - [Cell dealloc]
2013-10-09 17:42:47.264 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013- 10-09 17:42:47.268 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.289 CollViewSmpl [9547:a0b] - [Cell dealloc]
2013 -10-09 17:42:47.290 CollViewSmpl [9547:a0b] - [Cell dealloc]
2013-10-09 17:42:47.317 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.322 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.343 CollViewSmpl [9547:a0b] - [Cell dealloc]
2013-10-09 17:42:47.344 CollViewSmpl [9547:a0b] - [Cell dealloc]
2013-10-09 17:42:47.364 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.367 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.401 CollViewSmpl [9547:a0b] - [Cell dealloc]
2013-10-09 17:42:47.402 CollViewSmpl [9547:a0b] - [Cell dealloc]
2013-10-09 17:42:47.430 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.432 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.472 CollViewSmpl [9547:a0b] - [ ]
2013-10-09 17:42:47.472 CollViewSmpl [9547:a0b] - [Cell dealloc]
2013-10-09 17:42:47.498 CollViewSmpl [9547:a0b] - [Cell initWithCoder :]
2013-10-09 17:42:47.505 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.561 CollViewSmpl [9547:a0b] - [ Cell dealloc]
2013-10-09 17:42:47.562 CollViewSmpl [9547:a0b] - [Cell dealloc]
2013-10-09 17:42:47.585 CollViewSmpl [9547:a0b] - [ Cell initWithCoder:]
2013-10-09 17:42:47.587 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.624 CollViewSmpl [9547:a0b] - [Cell dealloc]
2013-10-09 17:42:47.624 CollViewSmpl [9547:a0b] - [Cell dealloc]
2013-10-09 17:42:47.669 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.674 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.797 CollViewSmpl [9547: a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.799 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.809 CollViewSmpl [ 9547:a0b] - [Cell dealloc]
2013-10-09 17:42:47.809 CollViewSmpl [9547:a0b] - [Cell dealloc]
2013-10-09 17:42:47.810 CollViewSmpl [ 9547:a0b] - [Cell dealloc]
2013-10-09 17:42:47.810 CollViewSmpl [9547:a0b] - [Cell dealloc]
2013-10-09 17:42:47.964 CollViewSmpl [ 9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.966 CollViewSmpl [9547:a0b] - [Cell initWithCoder:]
2013-10-09 17:42:47.987 CollViewSmpl [9547:a0b] - [Cell dealloc]
2013-10-09 17:42:47.987 CollViewSmpl [9547:a0b] - [Cell dealloc]

iOS 6装置(iPhone 5)



  2013-10-09 17:45:42.173 CollViewSmpl [187:907]  -  [Cell initWithCoder:] 
2013-10-09 17:45:42.191 CollViewSmpl [187:907] - [Cell initWithCoder: ]
2013-10-09 17:45:42.205 CollViewSmpl [187:907] - [Cell initWithCoder:]
2013-10-09 17:45:42.217 CollViewSmpl [187:907] - [ initWithCoder:]
2013-10-09 17:45:42.230 CollViewSmpl [187:907] - [Cell initWithCoder:]
2013-10-09 17:45:42.242 CollViewSmpl [187:907] [Cell initWithCoder:]
2013-10-09 17:45:42.253 CollViewSmpl [187:907] - [Cell initWithCoder:]
2013-10-09 17:45:42.264 CollViewSmpl [187:907 ] - [Cell initWithCoder:]
2013-10-09 17:45:43.630 CollViewSmpl [187:907] - [Cell initWithCoder:]
2013-10-09 17:45:43.640 CollViewSmpl [187 :907] - [Cell initWithCoder:]
2013-10-09 17:45:43.697 CollViewSmpl [187:907] - [cell prepareForReuse]
2013-10-09 17:45:43.706 CollViewSmpl [ 187:907] - [cell prepareForReuse]
2013-10-09 17:45:43.777 CollViewSmpl [187:907] - [cell prepareForReuse]
2013-10-09 17:45:43.791 CollViewSmpl [ 187:907] - [cell prepareForReuse]
2013-10-09 17:45:43.844 CollViewSmpl [187:907] - [cell prepareForReuse]
2013-10-09 17:45:43.855 CollViewSmpl [ 187:907] - [cell prepareForReuse]
2013-10-09 17:45:43.927 CollViewSmpl [187:907] - [cell prepareForReuse]
2013-10-09 17:45:43.937 CollViewSmpl [ 187:907] - [cell prepareForReuse]
2013-10-09 17:45:44.027 CollViewSmpl [187:907] - [cell prepareForReuse]
2013-10-09 17:45:44.037 CollViewSmpl [ 187:907] - [cell prepareForReuse]
2013-10-09 17:45:44.144 CollViewSmpl [187:907] - [cell prepareForReuse]
2013-10-09 17:45:44.155 CollViewSmpl [ 187:907] - [Cell prepareForReuse]
2013-10-09 17:45:44.311 CollViewSmpl [187:907] - [cell prepareForReuse]
2013-10-09 17:45:44.324 CollViewSmpl [ 187:907] - [cell prepareForReuse]
2013-10-09 17:45:44.560 CollViewSmpl [187:907] - [cell prepareForReuse]
2013-10-09 17:45:44.571 CollViewSmpl [ 187:907] - [cell prepareForReuse]
2013-10-09 17:45:45.027 CollViewSmpl [187:907] - [cell prepareForReuse]
2013-10-09 17:45:45.040 CollViewSmpl [ 187:907] - [cell prepareForReuse]
2013-10-09 17:45:45.397 CollViewSmpl [187:907] - [cell prepareForReuse]
2013-10-09 17:45:45.407 CollViewSmpl [ 187:907] - [cell prepareForReuse]
2013-10-09 17:45:45.494 CollViewSmpl [187:907] - [cell prepareForReuse]
2013-10-09 17:45:45.503 CollViewSmpl [ iOS 7设备(iPhone 5s)
strong>

  2013-10-09 17:44:37.603 CollViewSmpl [871:60b]  -  [Cell initWithCoder:] 
2013-10-09 17:44:38.015 CollViewSmpl [871:60b] - [Cell initWithCoder:]
2013-10-09 17:44:38.029 CollViewSmpl [871:60b] - [Cell initWithCoder:]
2013-10-09 17:44:38.037 CollViewSmpl [871:60b] - [Cell initWithCoder:]
2013-10-09 17:44:38.045 CollViewSmpl [871:60b] - [Cell initWithCoder :]
2013-10-09 17:44:38.053 CollViewSmpl [871:60b] - [Cell initWithCoder:]
2013-10-09 17:44:38.061 CollViewSmpl [871:60b] Cell initWithCoder:]
2013-10-09 17:44:38.071 CollViewSmpl [871:60b] - [Cell initWithCoder:]
2013-10-09 17:44:39.470 CollViewSmpl [871:60b] - [Cell initWithCoder:]
2013-10-09 17:44:39.483 CollViewSmpl [871:60b] - [Cell initWithCoder:]
2013-10-09 17:44:39.535 CollViewSmpl [871: 60b] - [Cell prepareForReuse]
2013-10-09 17:44:39.540 CollViewSmpl [871:60b] - [Cell prepareForReuse]
2013-10-09 17:44:39.583 CollViewSmpl [871: 60b] - [Cell prepareForReuse]
2013-10-09 17:44:39.587 CollViewSmpl [871:60b] - [Cell prepareForReuse]
2013-10-09 17:44:39.633 CollViewSmpl [871: 60b] - [Cell prepareForReuse]
2013-10-09 17:44:39.637 CollViewSmpl [871:60b] - [Cell prepareForReuse]
2013-10-09 17:44:39.683 CollViewSmpl [871: 60b] - [Cell prepareForReuse]
2013-10-09 17:44:39.688 CollViewSmpl [871:60b] - [Cell prepareForReuse]
2013-10-09 17:44:39.733 CollViewSmpl [871: 60b] - [cell prepareForReuse]
2013-10-09 17:44:39.737 CollViewSmpl [871:60b] - [Cell prepareForReuse]
2013-10-09 17:44:39.783 CollViewSmpl [871: 60b] - [Cell initWithCoder:]
2013-10-09 17:44:39.791 CollViewSmpl [871:60b] - [Cell initWithCoder:]
2013-10-09 17:44:39.866 CollViewSmpl [ 871:60b] - [Cell prepareForReuse]
2013-10-09 17:44:39.870 CollViewSmpl [871:60b] - [Cell prepareForReuse]
2013-10-09 17:44:39.933 CollViewSmpl [ 871:60b] - [Cell prepareForReuse]
2013-10-09 17:44:39.938 CollViewSmpl [871:60b] - [Cell prepareForReuse]
2013-10-09 17:44:40.033 CollViewSmpl [ 871:60b] - [Cell prepareForReuse]
2013-10-09 17:44:40.036 CollViewSmpl [871:60b] - [Cell prepareForReuse]
2013-10-09 17:44:40.149 CollViewSmpl [ 871:60b] - [Cell prepareForReuse]
2013-10-09 17:44:40.152 CollViewSmpl [871:60b] - [Cell prepareForReuse]
2013-10-09 17:44:40.300 CollViewSmpl [ 871:60b] - [Cell prepareForReuse]
2013-10-09 17:44:40.304 CollViewSmpl [871:60b] - [Cell prepareForReuse]
2013-10-09 17:44:40.650 CollViewSmpl [ 871:60b] - [Cell prepareForReuse]
2013-10-09 17:44:40.652 CollViewSmpl [871:60b] - [Cell prepareForReuse]

您可以知道在iOS 6和7中重复使用之间有一些变化,因为1)它在模拟器中不起作用,2)如果你做一个真正快速的滚动开始时,单元格不是最初准备重用,所以它必须创建一个新的,以弥补iOS 6没有(看我的日志)。



有一天我试图修复一个只在模拟器上发生的错误。


I am having trouble with reuse cells and UICollectionView on iOS 7. My code works fine on iOS 6 but in iOS 7 it does not reuse the cell after calling dequeueReusableCellWithReuseIdentifier (do not call prepareForReuse).

Even this code https://developer.apple.com/library/ios/samplecode/CollectionView-Simple/Introduction/Intro.html#//apple_ref/doc/uid/DTS40012860 does not reuse cell on iOS7 (but works well on iOS6), on every dequeueReusableCellWithReuseIdentifier it creates a new cell and deallocates the old one. Is there some new stuff that prevents cells to be reused?

My cells are big enough that they it is very inefficient to not reuse them. I've notice lag on iOS 7, but not on iOS 6, because they are not being reused in iOS 7.

解决方案

Update 2:
It turns out that this answer is not correct. Please see the answer below or by clicking this link http://stackoverflow.com/a/20147799/814389 instead.


Update

So I have revisited this answer since as I have found out a little more about this bug..

I grabbed all the devices I had available to me and ran the same tests on each one and these were the results:

DEVICE          OS Version      CELL REUSE
=============   =============   =============
iPad 4          7.0.0           YES
iPad 4          7.0.3           YES
iPad 3          7.0.3           NO
iPad 2          7.0.3           NO
iPad Mini       7.0.0           YES
iPad Mini       7.0.3           YES
iPhone 5s       7.0.3           YES
iPhone 4        7.0.2           YES
iPhone 4        7.0.3           YES

As you can see, it looks like for some reason cell reuse is not working on older iPads (ones that aren't capable of rendering the blurs).

I initially thought that Apple may have just prevented reuse on older iPads due to some sort of performance issue but if that was to have made sense, the iPhone 4 would also show the same results.

To get around this issue in my application, I have a NSMutableDictionary in my collectionViewController and I am storing my cells in there with the key being the indexPath.. In my case this is OK as I only have around 9 cells and their indexPaths never change but if you needed something more flexible then maybe it would be a good idea to checkout PSTCollectionView (https://github.com/steipete/PSTCollectionView)


Just tested this out on a physical device.. and it seems to work fine on both iOS 7 and 6 but not iOS 7 Simulator!!!

Just put some logs in the collectionView sample:

@implementation Cell

- (id)initWithCoder:(NSCoder *)aDecoder
{
    NSLog(@"%s",__func__);
    self = [super initWithCoder:aDecoder];
    if (self)
    {
        CustomCellBackground *backgroundView = [[CustomCellBackground alloc] initWithFrame:CGRectZero];
        self.selectedBackgroundView = backgroundView;
    }
    return self;
}

-(void)prepareForReuse
{
    NSLog(@"%s",__func__);
}

-(void)dealloc
{
    NSLog(@"%s",__func__);
}

@end

Then scrolled to the bottom on all three devices and this was the output:

iOS 7 Simulator

2013-10-09 17:42:45.798 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:45.807 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:45.811 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:45.841 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:45.844 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:45.848 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:45.852 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:45.857 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.080 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.083 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.181 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.183 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.208 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.208 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.214 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.218 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.245 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.246 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.264 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.268 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.289 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.290 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.317 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.322 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.343 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.344 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.364 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.367 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.401 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.402 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.430 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.432 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.472 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.472 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.498 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.505 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.561 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.562 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.585 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.587 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.624 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.624 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.669 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.674 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.797 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.799 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.809 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.809 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.810 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.810 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.964 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.966 CollViewSmpl[9547:a0b] -[Cell initWithCoder:]
2013-10-09 17:42:47.987 CollViewSmpl[9547:a0b] -[Cell dealloc]
2013-10-09 17:42:47.987 CollViewSmpl[9547:a0b] -[Cell dealloc]

iOS 6 Device (iPhone 5)

2013-10-09 17:45:42.173 CollViewSmpl[187:907] -[Cell initWithCoder:]
2013-10-09 17:45:42.191 CollViewSmpl[187:907] -[Cell initWithCoder:]
2013-10-09 17:45:42.205 CollViewSmpl[187:907] -[Cell initWithCoder:]
2013-10-09 17:45:42.217 CollViewSmpl[187:907] -[Cell initWithCoder:]
2013-10-09 17:45:42.230 CollViewSmpl[187:907] -[Cell initWithCoder:]
2013-10-09 17:45:42.242 CollViewSmpl[187:907] -[Cell initWithCoder:]
2013-10-09 17:45:42.253 CollViewSmpl[187:907] -[Cell initWithCoder:]
2013-10-09 17:45:42.264 CollViewSmpl[187:907] -[Cell initWithCoder:]
2013-10-09 17:45:43.630 CollViewSmpl[187:907] -[Cell initWithCoder:]
2013-10-09 17:45:43.640 CollViewSmpl[187:907] -[Cell initWithCoder:]
2013-10-09 17:45:43.697 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:43.706 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:43.777 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:43.791 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:43.844 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:43.855 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:43.927 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:43.937 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:44.027 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:44.037 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:44.144 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:44.155 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:44.311 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:44.324 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:44.560 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:44.571 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:45.027 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:45.040 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:45.397 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:45.407 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:45.494 CollViewSmpl[187:907] -[Cell prepareForReuse]
2013-10-09 17:45:45.503 CollViewSmpl[187:907] -[Cell prepareForReuse]

iOS 7 Device (iPhone 5s)

2013-10-09 17:44:37.603 CollViewSmpl[871:60b] -[Cell initWithCoder:]
2013-10-09 17:44:38.015 CollViewSmpl[871:60b] -[Cell initWithCoder:]
2013-10-09 17:44:38.029 CollViewSmpl[871:60b] -[Cell initWithCoder:]
2013-10-09 17:44:38.037 CollViewSmpl[871:60b] -[Cell initWithCoder:]
2013-10-09 17:44:38.045 CollViewSmpl[871:60b] -[Cell initWithCoder:]
2013-10-09 17:44:38.053 CollViewSmpl[871:60b] -[Cell initWithCoder:]
2013-10-09 17:44:38.061 CollViewSmpl[871:60b] -[Cell initWithCoder:]
2013-10-09 17:44:38.071 CollViewSmpl[871:60b] -[Cell initWithCoder:]
2013-10-09 17:44:39.470 CollViewSmpl[871:60b] -[Cell initWithCoder:]
2013-10-09 17:44:39.483 CollViewSmpl[871:60b] -[Cell initWithCoder:]
2013-10-09 17:44:39.535 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:39.540 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:39.583 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:39.587 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:39.633 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:39.637 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:39.683 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:39.688 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:39.733 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:39.737 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:39.783 CollViewSmpl[871:60b] -[Cell initWithCoder:]
2013-10-09 17:44:39.791 CollViewSmpl[871:60b] -[Cell initWithCoder:]
2013-10-09 17:44:39.866 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:39.870 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:39.933 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:39.938 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:40.033 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:40.036 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:40.149 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:40.152 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:40.300 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:40.304 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:40.650 CollViewSmpl[871:60b] -[Cell prepareForReuse]
2013-10-09 17:44:40.652 CollViewSmpl[871:60b] -[Cell prepareForReuse]

You can tell that there have been some changes between reuse in iOS 6 and 7 because 1) It doesn't work in the simulator and 2) If you do a really fast scroll to begin with, the cells aren't initially ready for reuse so it has to create a new one to compensate where iOS 6 didn't (see my logs).

There goes half of my day trying to fix a bug that only happens on the simulator.

这篇关于UICollectionView不重用单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆