[英]Adding UITextField above Keyboard
I found this link how to create tool bar above keyboard. 我发现此链接如何在键盘上方创建工具栏。 But I don't use any textfield that I need to tap and show keyboard. 但我不需要使用任何文本字段即可点按并显示键盘。 My idea is press on "Leave comment" button and then keyboard with a text field will be appeared. 我的想法是按“离开评论”按钮,然后出现带有文本字段的键盘。
So in the link I've attached they seems use inputAccessoryView of text field you interact with. 因此,在我附加的链接中,它们似乎使用与您交互的文本字段的inputAccessoryView。 But in my case I don't have any text field. 但就我而言,我没有任何文本字段。
So first of all I need to toggle keyboard without text field and then show keyboard with a textfield like a bar above keyboard. 因此,首先,我需要切换没有文本字段的键盘,然后显示带有文本字段(如键盘上方的条)的键盘。 How can I make it? 我该怎么做?
Hello you need to put your UITextfield
outside the View, like this: 您好,您需要将UITextfield
放在View之外,如下所示:
ViewController.h ViewController.h
@property (strong, nonatomic) IBOutlet UITextField *_myTextField;
ViewController.m ViewController.m
UITextField *t = [UITextField new];
[self.view addSubview:t];
[t becomeFirstResponder];
t.inputAccessoryView = _myTextField;
see the result: 查看结果:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.