gpt4 book ai didi

iphone - iPhone 中的数字键盘不显示返回键

转载 作者:行者123 更新时间:2023-12-03 18:28:32 26 4
gpt4 key购买 nike

我是 iPhone 技术新手。我已在 iPhone 应用程序中保存了一个问题,但是当我使用文本字段键盘类型数字键盘时,键盘不显示返回/完成按钮。

在文本字段中输入数字后如何隐藏数字键盘?你有什么解决办法吗?请提供帮助。

最佳答案

您可以通过以下方式执行此操作:

@property (nonatomic, strong) UITextField *textField;

- (void)viewDidLoad {
[super viewDidLoad];

self.textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
UIBarButtonItem *doneItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonDidPressed:)];
UIBarButtonItem *flexableItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:NULL];
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, [[self class] toobarHeight])];
[toolbar setItems:[NSArray arrayWithObjects:flexableItem,doneItem, nil]];
self.textField.inputAccessoryView = toolbar;
}

- (void)doneButtonDidPressed:(id)sender {
[self.textField resignFirstResponder];
}

+ (CGFloat)toolbarHeight {
// This method will handle the case that the height of toolbar may change in future iOS.
return 44.f;
}

关于iphone - iPhone 中的数字键盘不显示返回键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5833216/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com