Files
keyboard/CustomKeyboard/View/KBResponderUtils.h
2025-11-04 16:37:24 +08:00

29 lines
846 B
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// KBResponderUtils.h
// CustomKeyboard
//
// 统一封装:从任意 UIView/UIResponder 起,向响应链上查找 UIInputViewController。
// 作为 headeronly 的工具,便于多处直接引入使用。
//
#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 */