9

collectionViewFlowLayout bir alt sınıf yaptım. Bundan sonra, aşağıdaki kod kullanmaktadır: ayıklayıcı bu hata mesajını atar yöntemi: ViewFlowLayout Tuhaf hata alıyorum

override func finalLayoutAttributesForDisappearingItemAtIndexPath(itemIndexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? { 
     let attr = self.layoutAttributesForItemAtIndexPath(itemIndexPath) 
     attr?.transform = CGAffineTransformRotate(CGAffineTransformMakeScale(0.8, 0.8), CGFloat(M_PI)) 
     attr?.center = CGPointMake(CGRectGetMidX(self.collectionView!.bounds), CGRectGetMidY(self.collectionView!.bounds)) 
     return attr 
    } 

Ben performBatchUpdates kullanarak toplama görünümünde öğeleri silmek

. Silme işlemi gerçekten başarılı ve tamamen çalışıyor, ancak bu hata ayıklayıcı çıktı hakkında biraz kafam karıştı. Birisi lütfen lütfen hata ayıklayıcıyı yapmak için yapmalı mıyım? Hangi kodu ve nereye ekleneceğini anlamıyorum.

// HATA MESAJI önce onu kopyalamadan niteliğini manipüle çünkü hata oluşur

2015-08-02 12:39:42.208 nameOfMyProject[1888:51831] Logging only once for UICollectionViewFlowLayout cache mismatched frame 2015-08-02 12:39:42.209 nameOfMyProject[1888:51831] UICollectionViewFlowLayout has cached frame mismatch for index path {length = 2, path = 0 - 11} - cached value: {{106.13333333333333, 131.13333333333333}, {75.733333333333348, 75.733333333333348}}; expected value: {{192.5, 288}, {94.666666666666671, 94.666666666666671}}

2015-08-02 12:39:42.209 nameOfMyProject[1888:51831] This is likely occurring because the flow layout subclass nameOfMyProject.ShopLayout is modifying attributes returned by UICollectionViewFlowLayout without copying them

2015-08-02 12:39:42.209 nameOfMyProject[1888:51831] Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.

+0

bu sadece mü Xcode 7 ile başlayalım mı? Xcode 7 (ve iOS9'u yükleyerek) güncellemesinden bu yana bana da çok benzer bir şey geldi. Ben Obj-C, hızlı değil, ama hata, onları değiştirmeden önce öznitelikleri kopyalamamanızı söylüyor. NSArray * allAttributesInArray = [[super layoutAttributesForElementsInRect: rect] copy]; '' bunları manipüle etmeden önce bir şey yapmayı denedim, ancak bu da işe yaramıyor. – wanderingme

+0

xcode 7'den önce hiçbir zaman koleksiyon görünümü kullanmıyorum. Alt sınıfsız eski bir akışLayout kullanarak sonlandırdım, bu yüzden gerçekten bir cevap veremiyorum – brumbrum

+0

@wanderingme bunu nasıl çözeceğinizi öğrendiniz mi? Bende aynı olan var ve hiçbir şey onu çözmeye yardım etmedi. – Solomiya

cevap

9

. Eğer layoutAttributesForElementsInRect(rect: CGRect) aynı hataya rastlamak zaman sadece dizi kopyalamak yerine dizideki öğelerin her kopyalamak zorunda

override func finalLayoutAttributesForDisappearingItemAtIndexPath(itemIndexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? { 
    let attr = self.layoutAttributesForItemAtIndexPath(itemIndexPath)?.copy() as! UICollectionViewLayoutAttributes 
    // manipulate the attr 
    return attr 
} 

: Yani bu hatayı düzeltmek gerekir

override func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionViewLayoutAttributes]? { 
     let attributes = super.layoutAttributesForElementsInRect(rect) 
     var attributesCopy = [UICollectionViewLayoutAttributes]() 
     for itemAttributes in attributes! { 
      let itemAttributesCopy = itemAttributes.copy() as! UICollectionViewLayoutAttributes 
      // manipulate itemAttributesCopy 
      attributesCopy.append(itemAttributesCopy) 
     } 
     return attributesCopy 
    } 
+0

layoutAttributesForElementsInRect içindeki tüm özniteliklerin kopyalanması uyarıları çözmüştür. –

+0

@Joern, bu çalışmıyor – Ranjit

+0

@Ranjit Yukarıdaki yorumlarda bahsedilen github sorununu incelediniz mi? (https://github.com/wtmoose/TLLayoutTransitioning/issues/26) – joern