使用自定义 inputView 将输入返回到 UITextfield
我创建了一个 UITextField 和一个自定义视图。 之后,我将此自定义视图作为“inputView”添加到我的 UITextField 中。
amountKeyboardViewController *amountKeyboard = [[amountKeyboardViewController alloc] initWithNibName:@"amountKeyboardViewController" bundle:nil];
amountTextField.inputView = amountKeyboard.view;
[amountTextField becomeFirstResponder];
这工作得很好。但是我可以用在自定义视图(UIButtons)中单击的输入来填充“amountTextField”吗?
感谢您的一些提示!
i created a UITextField and a custom View.
after that i added this custom view as "inputView" to my UITextField.
amountKeyboardViewController *amountKeyboard = [[amountKeyboardViewController alloc] initWithNibName:@"amountKeyboardViewController" bundle:nil];
amountTextField.inputView = amountKeyboard.view;
[amountTextField becomeFirstResponder];
this works quite fine. but can i fill my "amountTextField" with the input clicked in my custom View (UIButtons)?
thanks for some hints !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的 amountTextField 控制器中,您需要在 .h 文件中编写以下代码
创建文本字段的属性
现在在 .m 文件中编写以下编写以下
语句,在其中创建 amountKeyboardViewController 对象
现在在 amountKeyboardViewController 控制器中编写以下代码,
然后创建此对象类
创建 Now 属性
然后单击按钮
in your amountTextField controller you need to write the following code in .h file
create property of your textfield
Now in .m file write the following
write following statement where you create object of amountKeyboardViewController
Now in amountKeyboardViewController controller write the following code
then create object of this class
then create property of
Now on click of button
您的意思是,如果您按 1,则文本字段中应显示“1”。
之后,如果您按 2,则会显示“12”。
你想要这样吗?
你必须为所有按钮编写IBaction
例如。
就像你必须为所有按钮编写 IBaction
You mean that if you press 1 then '1' should shown in textfield.
after that if you press 2 then it will show '12'.
Do you want like this?
You have to write IBaction for all buttons
eg.
like that you have to write IBaction for all your buttons