0

I have a view with 2 sub-views - collectionView and a custom view. I want to set an action to run after the 2 views have been laid out, but layouSubViews is running twice and I can't differentiate between the 2 instances, so my action is being called twice. How can I detect the instance that relates to the custom view only and trigger the action then?

Ran
  • 277
  • 4
  • 8

1 Answers1

0

Try calling layoutIfNeeded from outside and executing your action after that. layoutIfNeeded will internally call layoutSubviews, but by doing it outside you'll avoid being subject to whenever the system decides to call layoutSubviews.

rounak
  • 9,217
  • 3
  • 42
  • 59