mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-05 16:58:59 +00:00
29 lines
813 B
Objective-C
29 lines
813 B
Objective-C
//
|
|
// UIView+ViewController.m
|
|
// NewsBlur
|
|
//
|
|
// Created by Samuel Clay on 9/17/14.
|
|
// Copyright (c) 2014 NewsBlur. All rights reserved.
|
|
//
|
|
|
|
#import "UIView+ViewController.h"
|
|
|
|
@implementation UIView (ViewController)
|
|
|
|
- (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;
|
|
}
|
|
}
|
|
|
|
@end
|