2017-03-05 10 views
0

UICollectionsViewの下にマップビュー(MapKitではありません)があり、マップをパン/ズームすることを許可しますが、UICollectionViewは全体を占めるように設定されていますそれは、静的なままのすべてのタッチイベントを傍受します。UICollectionViewの空白部分でタッチやジェスチャーを無視する

これは私が現在持っているもので、UICollectionViewをフルスクリーンに設定している理由は、すべての画面空間内でセルの位置を個別にアニメーション化できるからです。

enter image description here

私はスウィフトでthis answerを書き換えてみたが、それはnil when unwrappingを投げています:

override func point(inside point: CGPoint, with event: UIEvent?) -> Bool { 
    let indexPath: IndexPath? = self.indexPathForItem(at: point) 
    let cell: UICollectionViewCell? = (self.cellForItem(at: indexPath!)) 
    if (cell != nil) && convert(point, to: cell?.contentView).x >= 0 { 
     return true 
    } 
    return false 
} 

答えて

1

はそれを考え出しました。タッチイベントがセル内で発生したかどうかを検出するのではなく、イベントが特定のyポイントを過ぎて発生したかどうかを確認し、それに応じて処理しました。 cardContainerYは、現在フォーカスカードのオフに計算していますCGFloatある

override func point(inside point: CGPoint, with event: UIEvent?) -> Bool { 
    if point.y > cardContainerY { 
     return true 
    } 
    return false 
} 

(カードを拡張することができるので、y空間内を移動)。

関連する問題