LoginSignup
0
1

More than 3 years have passed since last update.

UICorectionViewで指定したCellへ移動する処理

Posted at

当日cellへ移動処理表示後のUIViewControllerのライフサイクルのviewDidAppear
にてscrollToItemを利用してスクロールとanimated: false指定で処理。

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        print("aaaaaaaaaaaaaaaaa")
        let indexPath = IndexPath(item: elapsedDays + 5, section: 0)
        myCollectView.scrollToItem(at: indexPath, at: .centeredVertically, animated: false)
     //tableViewではitemがrowで指定する。
        //myCollectView.scrollToItem(at: IndexPath(row: 100, section: 0), at: .left, animated: false)
        //myCollectView.reloadData()
    }
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1