react-native-video/ios/Video/UIView+FindUIViewController.swift
Nick Fujita 8b75438148
VEX-5682: iOS Swift Conversion (#11)
Converts ios implementation from objective-c to swift.
2021-10-27 10:35:07 +09:00

19 lines
654 B
Swift

// Source: http://stackoverflow.com/a/3732812/1123156
extension UIView {
func firstAvailableUIViewController() -> UIViewController? {
// convenience function for casting and to "mask" the recursive function
return traverseResponderChainForUIViewController()
}
func traverseResponderChainForUIViewController() -> UIViewController? {
if let nextUIViewController = next as? UIViewController {
return nextUIViewController
} else if let nextUIView = next as? UIView {
return nextUIView.traverseResponderChainForUIViewController()
} else {
return nil
}
}
}