修改功能

This commit is contained in:
2025-10-30 13:27:09 +08:00
parent 9b43274e93
commit 74476cd592
3 changed files with 56 additions and 7 deletions

View File

@@ -20,8 +20,8 @@
- (instancetype)initWithFrame:(CGRect)frame{
if (self = [super initWithFrame:frame]) {
self.backgroundColor = [UIColor clearColor];
_leftTitles = @[@"帮回", @"会说", @"话术", @"更多"];
_rightTitles = @[@"❤", @"收藏", @"宫格"];
_leftTitles = @[@"ABC"];
_rightTitles = @[@"Upgrade VIP"];
[self buildUI];
}
return self;
@@ -56,7 +56,7 @@
// 4
NSMutableArray<UIButton *> *leftBtns = [NSMutableArray arrayWithCapacity:4];
UIView *prev = nil;
for (NSInteger i = 0; i < 4; i++) {
for (NSInteger i = 0; i < self.leftTitles.count; i++) {
UIButton *btn = [self buildButtonWithTitle:(i < self.leftTitles.count ? self.leftTitles[i] : [NSString stringWithFormat:@"L%ld", (long)i])];
btn.tag = 100 + i;
[btn addTarget:self action:@selector(onLeftTap:) forControlEvents:UIControlEventTouchUpInside];
@@ -81,7 +81,7 @@
// 3
NSMutableArray<UIButton *> *rightBtns = [NSMutableArray arrayWithCapacity:3];
UIView *next = nil;
for (NSInteger i = 0; i < 3; i++) {
for (NSInteger i = 0; i < self.rightTitles.count; i++) {
UIButton *btn = [self buildButtonWithTitle:(i < self.rightTitles.count ? self.rightTitles[i] : [NSString stringWithFormat:@"R%ld", (long)i])];
btn.tag = 200 + i;
[self.rightContainer addSubview:btn];

View File

@@ -232,9 +232,39 @@ static NSString * const kKBFunctionTagCellId = @"KBFunctionTagCellId";
}
}
}
- (void)onTapDelete { NSLog(@"点击:删除"); }
- (void)onTapClear { NSLog(@"点击:清空"); }
- (void)onTapSend { NSLog(@"点击:发送"); }
- (void)onTapDelete {
NSLog(@"点击:删除");
// 宿 App
UIInputViewController *ivc = [self findInputViewController];
id<UITextDocumentProxy> proxy = ivc.textDocumentProxy;
[proxy deleteBackward];
}
- (void)onTapClear {
NSLog(@"点击:清空");
//
UIInputViewController *ivc = [self findInputViewController];
id<UITextDocumentProxy> proxy = ivc.textDocumentProxy;
//
NSInteger guard = 0;
while (proxy.hasText && guard < 10000) { //
NSString *before = proxy.documentContextBeforeInput ?: @"";
// before
NSInteger count = before.length > 0 ? before.length : 1;
for (NSInteger i = 0; i < count; i++) {
[proxy deleteBackward];
}
guard += count;
}
//
self.pasteView.placeholderLabel.text = @"点击粘贴TA的话";
}
- (void)onTapSend {
NSLog(@"点击:发送");
// App
UIInputViewController *ivc = [self findInputViewController];
id<UITextDocumentProxy> proxy = ivc.textDocumentProxy;
[proxy insertText:@"\n"];
}
#pragma mark - Lazy
@@ -354,4 +384,18 @@ static NSString * const kKBFunctionTagCellId = @"KBFunctionTagCellId";
- (UIButton *)clearButton { return self.clearButtonInternal; }
- (UIButton *)sendButton { return self.sendButtonInternal; }
#pragma mark - Find Owner Controller
// 宿 UIInputViewControllerKeyboardViewController
- (UIInputViewController *)findInputViewController {
UIResponder *responder = self;
while (responder) {
if ([responder isKindOfClass:[UIInputViewController class]]) {
return (UIInputViewController *)responder;
}
responder = responder.nextResponder;
}
return nil;
}
@end

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array/>
</plist>