1
This commit is contained in:
@@ -28,27 +28,12 @@ static CGFloat KEYBOARDHEIGHT = 256;
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
//
|
||||
// // Perform custom UI setup here
|
||||
// self.nextKeyboardButton = [UIButton buttonWithType:UIButtonTypeSystem];
|
||||
//
|
||||
// [self.nextKeyboardButton setTitle:NSLocalizedString(@"Next Keyboard", @"Title for 'Next Keyboard' button") forState:UIControlStateNormal];
|
||||
// [self.nextKeyboardButton sizeToFit];
|
||||
// self.nextKeyboardButton.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
//
|
||||
// [self.nextKeyboardButton addTarget:self action:@selector(handleInputModeListFromView:withEvent:) forControlEvents:UIControlEventAllTouchEvents];
|
||||
//
|
||||
// [self.view addSubview:self.nextKeyboardButton];
|
||||
//
|
||||
// [self.nextKeyboardButton.leftAnchor constraintEqualToAnchor:self.view.leftAnchor].active = YES;
|
||||
// [self.nextKeyboardButton.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor].active = YES;
|
||||
|
||||
[self setupUI];
|
||||
}
|
||||
|
||||
|
||||
- (void)setupUI {
|
||||
// self.view.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
// 固定键盘整体高度
|
||||
[self.view.heightAnchor constraintEqualToConstant:KEYBOARDHEIGHT].active = YES;
|
||||
|
||||
@@ -74,38 +59,15 @@ static CGFloat KEYBOARDHEIGHT = 256;
|
||||
}
|
||||
|
||||
|
||||
- (void)viewWillLayoutSubviews
|
||||
{
|
||||
self.nextKeyboardButton.hidden = !self.needsInputModeSwitchKey;
|
||||
[super viewWillLayoutSubviews];
|
||||
}
|
||||
|
||||
- (void)textWillChange:(id<UITextInput>)textInput {
|
||||
// 文档内容即将变化,可在此做准备
|
||||
}
|
||||
|
||||
- (void)textDidChange:(id<UITextInput>)textInput {
|
||||
// 文档内容刚发生变化,环境已更新
|
||||
|
||||
UIColor *textColor = nil;
|
||||
if (self.textDocumentProxy.keyboardAppearance == UIKeyboardAppearanceDark) {
|
||||
textColor = [UIColor whiteColor];
|
||||
} else {
|
||||
textColor = [UIColor blackColor];
|
||||
}
|
||||
[self.nextKeyboardButton setTitleColor:textColor forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
#pragma mark - KBToolBarDelegate
|
||||
|
||||
- (void)toolBar:(KBToolBar *)toolBar didTapActionAtIndex:(NSInteger)index {
|
||||
// 可根据业务透传或处理。示例:插入占位标记 [A1]..[A4]
|
||||
NSString *placeholder = [NSString stringWithFormat:@"[A%ld]", (long)index+1];
|
||||
[self.textDocumentProxy insertText:placeholder];
|
||||
// NSString *placeholder = [NSString stringWithFormat:@"[A%ld]", (long)index+1];
|
||||
|
||||
}
|
||||
|
||||
- (void)toolBarDidTapSettings:(KBToolBar *)toolBar {
|
||||
// 通常可通过 openURL 或宿主处理打开设置页。
|
||||
// 这里示例仅插入一个标记。
|
||||
[self.textDocumentProxy insertText:@"[settings]"];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user