0

UIcollectionView でデフォルトの iOS デバイスの回転アニメーションを置き換えようとしています。transitionCoordinator で viewWillTransitionToSize と targetTransform() を使用して、デフォルトのビューの回転を防ぎ、変換を使用して各 visibleCell を正しい向きに回転させます。以下を除いて、正常に動作します。

  1. 可視四角形のすぐ外側の境界にあるセルは回転していません。
  2. 私のログは、collectionView.visibleCells() 配列が想定されているもの、つまり可視セルを提供していることを示していますが、デフォルトのアニメーションでビューを回転させると、visibleCells 配列が可視セルとセルを提供することがわかりましたすぐ近くにあります。
  3. これらの「近隣」セルにアクセスして回転できるようにしようとしましたが、すべての試行が失敗しました。

ViewWillTransitionTosize の私の実装は次のとおりです。

override func viewWillTransitionToSize( size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator){
       super.viewWillTransitionToSize(size , withTransitionCoordinator: coordinator)

      let transf : CGAffineTransform = coordinator.targetTransform()
      let invertedRotation = CGAffineTransformInvert(transf)
      let currentBounds = view.bounds
     coordinator.animateAlongsideTransition({
     _ in

     self.view.transform = CGAffineTransformConcat(self.view.transform, invertedRotation )
        self.undoRotation =  CGAffineTransformConcat(self.undoRotation, transf)
     self.view.bounds = currentBounds
}, completion: ({ finished in
         if ( finished != nil){

                 UIView.animateWithDuration(0.5,  animations: {
                 for cell  in self.collectionView!.visibleCells(){
                    cell.contentView.transform = self.undoRotation
                 }
             })}
         })
)

ここに簡単なgifがあります。問題を説明するには: http://www.blessinglopes.com/Info

どんな助けでも大歓迎です!ありがとうございました!

4

2 に答える 2

1

セルがアニメーション化される別のスレッドを実装することで問題を解決しました。以下の git リポジトリでコードを確認できます。

https://github.com/rakeshbs/RotatingCollectionView

于 2015-01-06T05:32:47.480 に答える