Detect when UIViewController no longer presents a view controller
I would like to observe the view controller that the view controller presents to determine when it stops presenting it.
I was thinking about trying KVO, which I'm not very familiar with:
[observedVC addObserver:self forKeyPath:NSStringFromSelector(@selector(presentedViewController)) options:0 context:NULL];
And then:
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
NSLog(@"Change: %@", keyPath);
}
But I don't see what caused it. Is there a better way to do this? I'm working on an SDK, so I don't necessarily have control over the observable VC.
+3
source to share
No one has answered this question yet
Check out similar questions: