Move View Controller retrieval to external UIView category

This commit is contained in:
Stanisław Chmiela
2016-03-31 20:51:22 +02:00
parent 8ebfa6e4db
commit 6ab72c4cb8
4 changed files with 49 additions and 20 deletions

View File

@@ -574,26 +574,6 @@ 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