1
This commit is contained in:
28
CustomKeyboard/View/KBResponderUtils.h
Normal file
28
CustomKeyboard/View/KBResponderUtils.h
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// KBResponderUtils.h
|
||||
// CustomKeyboard
|
||||
//
|
||||
// 统一封装:从任意 UIView/UIResponder 起,向响应链上查找 UIInputViewController。
|
||||
// 作为 header‑only 的工具,便于多处直接引入使用。
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#ifndef KBResponderUtils_h
|
||||
#define KBResponderUtils_h
|
||||
|
||||
/// 从给定 responder 开始,沿响应链查找宿主 UIInputViewController。
|
||||
/// 用法:UIInputViewController *ivc = KBFindInputViewController(self);
|
||||
static inline UIInputViewController *KBFindInputViewController(UIResponder *start) {
|
||||
UIResponder *responder = start;
|
||||
while (responder) {
|
||||
if ([responder isKindOfClass:[UIInputViewController class]]) {
|
||||
return (UIInputViewController *)responder;
|
||||
}
|
||||
responder = responder.nextResponder;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
#endif /* KBResponderUtils_h */
|
||||
|
||||
Reference in New Issue
Block a user