2016-02-15 13 views
5

Ben bir koleksiyon Görüntüleme yaşıyorum bulunamadı ve ben yeni bir düzen, log ile uygulama çöker ayar toplama görünümü dynamically.On düzenini değiştirmek zorunda setCollectionViewLayout çökmesine yol açar diyor kullanma, layoutAttributesForItemAtIndexPath

2016 -02-15 13: 47: 31.663 PhotoBoard [92347: 5235792] *** Onaylama hatası - [UICollectionViewData düzeniAttributesForItemAtIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.30.14 nedeniyle yakalanmamış istisna 'NSInternalInconsistencyException', akla uygulamayı sonlandırılması * 47:

2016-02-15 13 /UICollectionViewData.m:666: 31,666 PhotoBoard [5235792 92347]: ' -layoutAttributesForItemAtIndexPath için bir UICollectionViewLayoutAttributes örneği: {uzunluğu = 2, yol = 0-0} * İlk atış çağrı yığını: ( 0 CoreFoundation 0x000000010d94de65 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010f8b5deb objc_exception_throw + 48 2 CoreFoundation 0x000000010d94dcca + [NSException artış: biçim: parametreler:] + 106 3 Hazırlık 0x000000010dfbe4de - [NSAssertionHandler handleFailureInMethod: nesne: dosya: linenumber: açıklaması:] + 198 4 UIKit 0x000000010ec4161c - [UICollectionViewData layoutAttributesForItemAtIndexPath:] + 627 5 UIKit 0x000000010ebeee24 - [UICollectionView _setCollectionViewLayout: animasyonlu: isInteractive: tamamlama:] + 1606 6 UIKit 0x000000010ebee4db - [UICollectionView setCollectionViewLayout:] + 318 düzeni baskı ı layoutAttributesForItemAtIndexPath için bir düzen özelliği madde bkz özellikleri üzerinde

: {uzunluğu = 2, yol 0 = 0 -}', içinde bir giriş bakınız düzen, bu yüzden neden özellik özniteliği bulunamadığından emin değilsiniz,

Öznitelikler dizin yolu: ({length = 2, path = 0 - 0}); çerçeve = (6 293; 298 403.695);

Öznitelikler dizin yolu: ({length = 2, path = 0 - 1}); çerçeve = (6 293; 298 408.695);

Öznitelikler dizin yolu: ({length = 2, path = 0 - 2}); çerçeve = (6 293; 298 418.695);

Öznitelikler dizin yolu: ({length = 2, path = 0 - 3}); çerçeve = (6 293; 298 433.695);

Öznitelikler dizin yolu: ({length = 2, path = 0 - 4}); çerçeve = (6 293; 298 453.695);

Öznitelikler dizin yolu: ({length = 2, path = 0 - 5}); çerçeve = (6 293; 298 478.695);

Öznitelikler dizin yolu: ({length = 2, path = 0 - 6}); çerçeve = (6 293; 298 508.695);

Öznitelikler dizin yolu: ({length = 2, path = 0 - 7}); çerçeve = (6 293; 298 543.695);

Öznitelikler dizin yolu: ({length = 2, path = 0 - 8}); çerçeve = (6 293; 298 583.695);

Öznitelikler dizin yolu: ({length = 2, path = 0 - 9}); çerçeve = (6 293; 298 628.695);

Öznitelikler dizin yolu: ({length = 2, path = 0 - 10}); çerçeve = (6 293; 298 678.695);

Öznitelikler dizin yolu: ({length = 2, path = 0 - 11}); çerçeve = (6 293; 298 733.695);

Öznitelikler dizin yolu: ({length = 2, path = 0 - 12}); çerçeve = (6 293; 298 793.695);

Öznitelikler dizin yolu: ({length = 2, path = 0 - 13}); çerçeve = (6 293; 298 858.695);

Öznitelikler dizin yolu: ({length = 2, path = 0 - 14}); çerçeve = (6 293; 298 928.695);

Öznitelikler dizin yolu: ({length = 2, path = 0 - 15}); çerçeve = (6 293; 298 1003.69);

Bu benim statik olarak onlar iyi çalışır çarpışma düzeni dinamik olarak değiştirilebilir yalnızca olur iki özel düzenleri yüklerseniz ben yeni bir özel düzen,

self.collectionView!.collectionViewLayout = self.stackLayout 
     self.stackLayout.delegate = self 
     self.collectionView!.collectionViewLayout.invalidateLayout() 
     self.collectionView!.setCollectionViewLayout(self.stackLayout, animated:true) 
     self.collectionView?.reloadData() 

kuruyorum nasıl.

+0

Geçiş için startInteractiveTransitionToCollectionViewLayout kullanarak denedim, aynı sorun oluyor. –

+0

Aynı şeyi alıyorum. Bunun nereden geldiğini bulamıyorum. Nereye bakılacağı ve nasıl düzeltileceği ile ilgili bir açıklama harika olurdu. – markhorrocks

cevap

3

Aynı problem vardı ve bu benim problemimi çözüyor.

sen Swift, sonra hem özel düzen sınıflarında aşağıdaki yöntemleri geçersiz, geçiş için

- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect 
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath 

Örnek birden çok özel düzenleri kullanıyorsanız:

override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? { 
    return cache[indexPath.item] 
} 

Örnek Amaç C:

- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    return self.cache[indexPath.item]; 
} 

HAPPY CODING ..!