gpt4 book ai didi

iOS:数字键盘上是否可以有返回键?

转载 作者:行者123 更新时间:2023-12-01 19:01:43 43 4
gpt4 key购买 nike

iOS 中的标准键盘确实有一个返回键,并且当用户点击返回键时会调用一个委托(delegate)方法。

数字键盘上可以有返回键吗?

最佳答案

你可以做这样的事情,你可以设置你自己的工具栏位置。

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
if( textField == yourTextField )
{
UIToolbar* numberToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
numberToolbar.barStyle = UIBarStyleBlackTranslucent;
numberToolbar.items = [NSArray arrayWithObjects:
[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
[[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(doneButton)],nil];
textField.inputAccessoryView = numberToolbar;
}
}

- (void)doneButton
{
[youtTextField resignFirstResponder];
}

关于iOS:数字键盘上是否可以有返回键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22391584/

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