Add view controller finding functions

We need them to be able to present another view controller
This commit is contained in:
Stanisław Chmiela 2016-03-31 20:34:08 +02:00
parent 5bb20b6f9b
commit 9be76e3674

View File

@ -524,6 +524,26 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty";
}
}
#pragma mark - View Controller retrieval
// http://stackoverflow.com/questions/1340434/get-to-uiviewcontroller-from-uiview/2596519
- (UIViewController *) firstAvailableUIViewController {
// convenience function for casting and to "mask" the recursive function
return (UIViewController *)[self traverseResponderChainForUIViewController];
}
- (id) traverseResponderChainForUIViewController {
id nextResponder = [self nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]]) {
return nextResponder;
} else if ([nextResponder isKindOfClass:[UIView class]]) {
return [nextResponder traverseResponderChainForUIViewController];
} else {
return nil;
}
}
#pragma mark - Lifecycle
- (void)removeFromSuperview