2017-10-14 11 views
5

मैंने एक एकल दृश्य प्रोजेक्ट बनाया और एक संग्रह दृश्य जोड़ा। मैं स्वयंआईओएस 11 यूआईसीओलेक्शनसेक्शन हैडर क्लिपिंग स्क्रॉल सूचक

extension ViewController: UICollectionViewDataSource { 
    func numberOfSections(in collectionView: UICollectionView) -> Int { 
    return 1 
    } 

    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 
    return 100 
    } 

    func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { 
    let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: kHeader, for: indexPath) 
    return headerView 
    } 

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) 
    cell.backgroundColor = UIColor.blue 
    return cell 
    } 
} 

extension ViewController: UICollectionViewDelegateFlowLayout { 
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { 
    return CGSize(width: collectionView.bounds.width, height: 88) 
    } 
} 

को UICollectionReusableView

final class TestReusableView: UICollectionReusableView { 
    override init(frame: CGRect) { 
    super.init(frame: frame) 
    backgroundColor = UIColor.red 
    } 
    ... 
} 

सेट डेटा स्रोत और प्रतिनिधि का एक सरल उपवर्ग पंजीकृत परिणाम अनुभाग शीर्ष लेख लंबवत स्क्रॉल सूचक ऊपर तैनात किया जा रहा है है। हालांकि, अगर मैं 10.3.1 सिम्युलेटर के खिलाफ ऐप चलाता हूं, तो व्यवहार काम करता है जैसा कि मैं उम्मीद करता हूं।

Red section header is on top of the scroll indicator

+0

मैं भी आईओएस 11.0 जहां अनुभाग शीर्ष लेख सभी दृश्यों से ऊपर रखा जाता है के साथ इसी तरह इस मुद्दे का सामना करना पड़ा। सब कुछ 10.3 में ठीक काम करता है। – Aks

+2

निश्चित रूप से आईओएस 11.0+ अंक की तरह दिखता है। मैं भी इसमें भाग रहा हूँ। निकटतम रडार मैं यह पा सकता हूं: http://www.openradar.me/34308893 – isoiphone

उत्तर

1

मैं इसे आज़माने नहीं कर सकता है, लेकिन आप अपने viewDidLoad() को यह जोड़ने की कोशिश कर सकते हैं:

let flow = collectionView.collectionViewLayout as! UICollectionViewFlowLayout 
flow.sectionHeadersPinToVisibleBounds = true 
+0

यह सिर्फ संग्रह दृश्य के शीर्ष पर अनुभाग शीर्षलेख पिन करता है। प्रश्न में समस्या यह है कि सेक्शन हेडर लंबवत स्क्रॉल सूचक – CoderNinja

0

खैर यहां तक ​​कि मैं अपने अनुप्रयोग में एक ही मुद्दा का सामना करना पड़ा और उस में जारी करने के लिए शुरू किया गया था 2 सप्ताह। मेरे पास शोध करने का समय नहीं हो सकता है कि यह केवल आईओएस 11 में क्यों विफल रहा है। इसलिए मैंने जो काम किया है, उसके बारे में त्वरित कार्य हैडरव्यू के उपयोग को फूटर व्यू के साथ बदलकर फुटेज व्यू में यह समस्या नहीं है।

4

यह मेरे लिए काम करता है:

- (void)collectionView:(UICollectionView *)collectionView willDisplaySupplementaryView:(UICollectionReusableView *)view forElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath { 
    if (SystemVersionGraterOrEqual(11)) { 
     if ([elementKind isEqualToString:UICollectionElementKindSectionHeader]) { 
      view.layer.zPosition = 0; 
    } 
} 

}

+0

अच्छी पकड़ पकड़ रहे हैं, हालांकि पूरी समस्या एक बग की तरह लगती है, क्योंकि ज़ेड स्थिति के साथ खेलना आवश्यक नहीं होना चाहिए। –