-2

I would like to know if there is anyway I could get a callback everytime the displayed view changes and receive the newly displayed view as a parameter of the callback?

Can this be achieved with the key-value observing protocol?

Here is more details: I develop an SDK so I don't know what the client app is doing wrt controllers but I would like to know every time a new view controller is presented by the client app. Or in other terms, I would like to know when the displayed view on the UIWindow changes.

Thanks a lot for your help.

Daniyar
  • 2,975
  • 2
  • 26
  • 39
Dominic Jodoin
  • 2,538
  • 18
  • 21
  • 1
    What kind of view is this? How is it being updated? Is it a view you created or one from some third party library? – Gavin Feb 19 '14 at 15:41
  • I'm talking about the UIWindow of the app i.e. the main view updated everytime a new view controller is presented. – Dominic Jodoin Feb 19 '14 at 15:43
  • 1
    Why? Ask about the problem you are trying to solve, now what you think the solution might be. View changes are driven by your data so observe that. – Wain Feb 19 '14 at 15:46
  • @Wain: I want to do this in an SDK that would be integrated in an app I don't control. – Dominic Jodoin Feb 19 '14 at 15:48

1 Answers1

0

Here is the recipe that solves my problem: http://broutille.wordpress.com/2011/06/09/ios-how-to-monitor-the-change-of-viewcontrollers-inside-a-uinavigationcontroller/.

That and adding an observer for the "UIWindowDidBecomeKeyNotification" notification.

Dominic Jodoin
  • 2,538
  • 18
  • 21