rechsteiner / Parchment

A paging view with a highly customizable menu ✨
MIT License
3.35k stars 417 forks source link

Why collectionView.window is nil if the pagingController is not visible ? #717

Open aiKrice opened 3 months ago

aiKrice commented 3 months ago

Hello @rechsteiner I have noticed that if I pop a viewcontroller and in a row I change the selectIndex of the PagingViewController nothing is visible because collectictionView.window is nil .

I had to perform a DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) to make it work Any hint ?

File PagingController.swift, L67

rechsteiner commented 1 month ago

Hi! Yeah, the paging controller only allows changing the selected item when the view controller is visible. I guess you are calling select(pagingItem:) right after calling popViewController? In that case, the view controller will not yet be visible. Maybe you could use the completion handler on the transition controller like this?

navigationController.popViewController()
navigationController.transitionCoordinator?.animate(alongsideTransition: nil) { _ in
  // Select item
}
aiKrice commented 3 days ago

Hello ! Oh I will try and will come back to you :) Ty