I have a question that there is a textview in my custom keyboard, when I edit it, it become first responder, I can use my custom keyboard to edit it, then I remove it and resignFirstResponder, back to host App (not container app, not keyboard's home app), there is also have textview like chat frames, but it's useless when I use my custom keyboard to input char?
I think if I can communicate with host app and make host app become key window or become first responder? How to make it?
If there is no correct way to solve it, i'll try to use label not textview in my custom keyboard, just make label's text equal to char. So that, the host app's chat frames are always first responder.
Related
Currently I am walking through my whole iOS app to optimize it for accessibility voice over. When it comes to the UITextView, which I subclassed, voice over is not acting like I thought it would. My UITextView subclass is only changing a path's color on the superview's layer in becomeFirstResponder and resignFirstResponder. So nothing special on my UITextView subclass that could interfere with accessibility.
As long as there is no text in the UITextView it is acting as expected. Voiceover tells me that it is a text field and that I can double tap it to edit. But as soon as there is text in the UITextView, the only thing voice over tells me, is the value of the UITextView. Voice over doesn't tell me anymore that this is an editable text field.
Am I doing something wrong? Why is it acting like that?
I do appreciate any help!
If you didn't edit any accessibility hints or labels for the text field it should act accordingly. If selected it should say:
It is a text field
If you are editing it
The editing mode you are in
The value of the text field (nil if empty)
Where the cursor is
Then while you type it says the letters you are entering as you enter them. When you hit space or enter it should say the word you just typed. As long as your text field is exhibiting these behaviors you should be fine.
Tip: if you want to know how accessibility elements should act, try using a native iOS app with accessibility turned on and compare it with your app.
I want to know how to make the keyboard appear in an iOS Swift app and remain there permanently. I know it appears when the user touches inside a textfield. That's not what I want. I want it to be there when the user loads up the app and to stay there permanently. I do still want the keyboard to communicate with a textfield as it normally would.
I would also like to be able to use the keyboard in storyboard auto layout and scale/align my buttons around the keyboard, which is asked here:
Xcode storyboard layout size simulation - keyboard up?
What I tried:
If I could simulate a "touch" inside a textfield programmatically I think I can accomplish my task. I would forcibly simulate a "touch" once the app loads and then in the "textFieldShouldReturn" method I can repeat the forced programmatic touch inside the textfield to prevent the keyboard from disappearing. (This may cause the keyboard to disappear and then reappear quickly, which would be ugly and undesirable.) How do I force this fake touch?
In Conclusion:
I am using iOS Storyboard and Swift.
How do I cause a keyboard to load up on start up and remain there even after pressing return/send?
If the above is impossible, how do I programattically force a touch inside a textfield?
I think that you can't do this from storyboard side, but from code side, assuming that you name your textfield "textField", you can do self.textField.becomeFirstResponder() on your viewDidLoad() in order to make the keyboard appear when you enter on this screen. This should keep the keyboard on screen unless you do resignFirstResponder() elsewhere.
I have a custom inputView for a particular textfield, and it works well. However, I cannot discern how to dismiss the view and get the regular keyboard back. (I have a SWAP button right next to the TextField.) I tried setting the textfield's inputView to nil, but that did nothing.
I do not need a full custom keyboard, but I need more than an Accessory view above the keyboard, which is why I am trying this route. I need about 20 custom buttons in addition to the regular keyboard, and I do not like the idea of a huge Accessory view taking up so much space.
I also would rather not require the user to initially install a full custom keyboard before being able to use the app.
Thank you very much for any suggestions.
I think you will probably have to do this:
Call resignFirstResponder on the UITextField
After the animation finishes, set your inputView to nil
Call becomeFirstResponder on the text field
The keyboard animation duration is sent in the userInfo dictionary on the keyboard presentation notifications.
In addition to the accepted answer, you can use reloadInputViews() (and this is less likely to suffer any animation glitches resulting from the resignFirstResponder, becomeFirstResponder calls):
yourTextField.inputView = nil;
yourTextField.reloadInputViews();
Here's more info in the Apple's Docs.
I would like to programmatically change keyboard when I click a button event.
I used custom keyboard in my app, but I need to change English (US) keyboard in programmatically when I click a button on my custom keyboard.
The only way you can control the keyboard is by showing it (By setting a UITextView/UITextField as a first responder), hiding it (by resigning the editing Easy way to dismiss keyboard?).
The language of the keyboard cannot be changed by your app, since it is a user preference. If you want a custom keyboard of your own, you would have to design it yourself (with UIButtons) and obviously also program it (when it shows, when it hides. I would simply use the keyboard that the user prefers, why do you need to change it? After all, the user is the one that decides which keyboard he uses.
I just got my answer for my own question.
Just put nil into inputView and that will change back into English (US) Keyboard.
You can change to the English (US) keyboard programmatically.
Try this:
textfield.secureTextEntry=YES;
textfield.secureTextEntry=NO;
I'm creating an app that uses a custom keyboard, now if I provide the default English keyboard using the same globe icon that iOS uses, it should be able to switch to the default English keyboard fine, but I'm not sure if the user can return back to my custom keyboard from the system keyboards (assuming the user has more than 1 keyboards).
Can someone please confirm if that would be possible?
Thanks
It's not. the system keyboards have no "switch to custom keyboard" button. They're not even aware you made a custom keyboard.
What is it you're trying to accomplish? Why are you building a custom keyboard? If you tell us, maybe we can suggest an alternate way to do what you need to do.
You should set an inputAccessoryView in your UITextView with a button to toggle between your custom and the standard keyboards.
Every time the user taps the button you change myTextView.inputView between your custom keyboard and nil, which restores the original keyboard.
https://developer.apple.com/library/ios/documentation/uikit/reference/UITextField_Class/Reference/UITextField.html#//apple_ref/occ/instp/UITextField/inputView
You'll also need to reassign first responder, and also try to animate it if you want:
Animating UITextInput's textInputView
What you need is making a custom keyboard check this:
App Extension Programming Guide