iOS 10, the gift that keeps on breaking, seems to have changed another behavior.
Assume two UIViewControllers are pushed onto a UINavigationController.
On iOS 8/9, calling navigationController?.popViewController(animated: true)
to pop the top UIViewController (say VC2) caused viewDidLayoutSubviews
on the bottom view controller (say VC1) to get called.
We relied on this to refresh VC1. Sometimes VC2 adds subviews to VC1 (via the data model), and this needs to get reflected when popping back to VC1.
Accurate frame information is required. We can't use viewWillAppear
because frame data is wrong on iOS 9. The problem with viewDidAppear
is that there is a momentary glitch between seeing the view initially and the adjustment.
Now VC1's viewDidLayoutSubviews
does not get invoked when popping VC2.
1) Is this a bug for viewDidLayoutSubviews
to not get invoked?
2) What's the right way to refresh view controllers when popping with UINavigationController?
viewDidLayoutSubviews
is called at some point. Is it called together with the other controller (VC2)? – Léo NatanviewDidLayoutSubviews
, that's not good. – Léo NatanviewWillAppear
and add/update any new views as well. The new views should be setup based on the view controller's view size at the time.viewDidLayoutSubviews
can be used as normal to adjust the subview's frames. – rmaddy