2012-09-29 8 views
12

मेरे पास UICollectionViewLayout का उप-वर्ग है जो किसी मंडली में कक्ष रखता है। लेआउट YES कॉल shouldInvalidateLayoutForBoundsChange: पर कॉल के लिए देता है। रोटेशन पर, प्रारंभिक स्थिति में सेल फ़ेड आउट और अंतिम स्थिति में सेल में fades।UICollectionView/UICollectionViewLayout पर क्रॉस फेड को अक्षम करने का सबसे अच्छा तरीका क्या है या परिवर्तनों को बाध्य करता है?

मैं fades अक्षम कर सकते हैं और वस्तुओं के चक्र बस को प्रतीत होता है मेरी लेआउट के लिए निम्न कोड को जोड़ कर उन्मुखीकरण परिवर्तन के साथ बारी बारी से:

- (UICollectionViewLayoutAttributes *)initialLayoutAttributesForAppearingItemAtIndexPath:(NSIndexPath *)itemIndexPath { 
    return nil; 
} 

- (UICollectionViewLayoutAttributes *)finalLayoutAttributesForDisappearingItemAtIndexPath:(NSIndexPath *)itemIndexPath { 
    return [self layoutAttributesForItemAtIndexPath:itemIndexPath]; 
} 

क्यों तरीकों एक सीमा परिवर्तन पर बुलाया मिलता है क्योंकि प्रलेखन नहीं है वे करते हैं सुझाव है कि लगता है? प्रलेखन को लगता है कि संग्रह दृश्य से आइटमों को सम्मिलित करने और हटाने के लिए उन्हें संबंधित कहा जाता है।

क्या घूर्णन के दौरान क्रॉस फीड को अक्षम करने का कोई बेहतर तरीका है?

नोट्स:

  • initialLayoutAttributesForAppearingItemAtIndexPath: प्रलेखन कहा गया है कि डिफ़ॉल्ट रूप से विधि रिटर्न nil लेकिन कॉल super लौटे गैर शून्य मूल्यों के लिए।
  • मैं UICollectionView तरीकों deleteItemsAtIndexPaths:, moveItemAtIndexPath:toIndexPath: और insertItemsAtIndexPaths: पर प्रतीकात्मक टूटता अंक की स्थापना की और उनमें से कोई भी रोटेशन के दौरान मारा गया है।
+0

यह अंधेरे में सिर्फ एक शॉट है, लेकिन रोटेशन एनीमेशन को अक्षम करने के लिए, आप रोटेशन ऑपरेशन के लिए पूरी तरह कोर एनीमेशन बंद कर सकते हैं: [CATransaction प्रारंभ]; [कैट्रानैक्शन सेट वैल्यू: (आईडी) केसीएफबोलियन फल्से के लिए: केसीएट्रानएक्शनडिसेबलएक्शन]; // अपना रोटेशन [कैट्रानक्शन प्रतिबद्धता] करें; – maz

+0

हो सकता है कि आंतरिक रूप से सीमाओं पर आइटमों को हटा दिया जाए और जोड़ा जाए और परिणामस्वरूप विधियों को बुलाया जाए। क्यों -deleteItemsAtIndexPaths: और -insertItemsAtIndexPaths: कॉल न करें .. यहां कोई सुराग नहीं है। शायद यूआईकिट प्रोग्रामर ने धोखा दिया और डालने और हटाने के लिए एपीआई से परहेज किया? अभूतपूर्व नहीं है। – maz

+1

क्या आप यहां कुछ वर्णन करते हुए दृश्य की बैकिंग परत पर अंतर्निहित एनिमेशन अक्षम कर सकते हैं: http://stackoverflow.com/questions/2244147/disabling-implicit-animations-in-calayer-setneedsdisplayinrect/2244734#2244734? –

उत्तर

10

UICollectionViewLayout.h फ़ाइल राज्यों

// This set of methods is called when the collection view undergoes an 
    animated transition such as a batch update block or an animated 
    bounds change. 
// For each element on screen before the invalidation, 
    finalLayoutAttributesForDisappearingXXX will be called and an 
    animation setup from what is on screen to those final attributes. 
// For each element on screen after the invalidation, 
    initialLayoutAttributesForAppearingXXX will be called an an 
    animation setup from those initial attributes to what ends up on 
    screen. 

जो स्पष्ट रूप से कहते हैं कि वे सीमा परिवर्तन पर कहा जाता है। हटाने/सम्मिलन के बजाय, "पुराना राज्य" और "नया राज्य" अधिक सटीक लगता है।