测试假数据
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
//
|
||||
|
||||
#import "KBStreamTextView.h"
|
||||
#import "KBResponderUtils.h" // 通过响应链找到 UIInputViewController,并将文本输出到宿主
|
||||
|
||||
@interface KBStreamTextView ()
|
||||
|
||||
@@ -170,7 +171,7 @@
|
||||
label.textColor = self.labelTextColor;
|
||||
label.userInteractionEnabled = YES;
|
||||
label.text = @"";
|
||||
|
||||
label.backgroundColor = [UIColor redColor];
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleLabelTap:)];
|
||||
[label addGestureRecognizer:tap];
|
||||
|
||||
@@ -256,8 +257,19 @@
|
||||
UILabel *label = (UILabel *)tap.view;
|
||||
if (![label isKindOfClass:[UILabel class]]) { return; }
|
||||
NSInteger index = [self.labels indexOfObject:label];
|
||||
NSString *text = label.text ?: @"";
|
||||
if (index != NSNotFound && self.onLabelTap) {
|
||||
self.onLabelTap(index, label.text ?: @"");
|
||||
self.onLabelTap(index, text);
|
||||
}
|
||||
|
||||
// 将文本发送到当前宿主应用的输入框(搜索框/TextView 等)
|
||||
// 注:键盘扩展无需“完全访问”也可 insertText:
|
||||
UIInputViewController *ivc = KBFindInputViewController(self);
|
||||
if (ivc) {
|
||||
id<UITextDocumentProxy> proxy = ivc.textDocumentProxy;
|
||||
if (text.length > 0 && [proxy conformsToProtocol:@protocol(UITextDocumentProxy)]) {
|
||||
[proxy insertText:text];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user