2017-10-14 9 views
5

私は単一のビュープロジェクトを作成し、collectionViewを追加しました。私は自己iOS11 UICollectionSectionHeaderクリッピングスクロールインジケータ

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

私もセクションヘッダは、すべてのビューの上に配置されているiOSの11.0と同様の問題に遭遇しました。すべて10.3でうまく動作します。 – Aks

+2

iOS 11.0+の問題のようです。私はそれにも走っています。私が見つけることができる最も近いRADARは、次のとおりです。http://www.openradar.me/34308893 – isoiphone

答えて

1

私はそれを試してみることができませんでしたが、あなたはあなたのviewDidLoad()にこれを追加してみてくださいすることができます

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

これは、セクションヘッダをcollectionViewの上部にピン止めするだけです。問題の問題は、セクションヘッダーが垂直スクロールインジケータをクリップしていることです。 – CoderNinja

0

まあでも、私は私のアプリで同じ問題に遭遇し、それはにリリース予定だったが2週間。私はこれがなぜiOS 11でのみ失敗するのかを研究する時間がありませんでした。したがって、私がやった簡単なやり方は、footerViewにこの問題がないのでheaderViewの使い方をfooterViewに置き換えることです。

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

z位置での再生が必要ではないので、問題は全体的にバグのように見えますが、良いキャッチです。 –

関連する問題