As you can see in the below gif there is a flash as the keyboard momentarily dismisses as the input in the home screen loses focus and reopens as the text field in the second screen gains focus. Is there a way to keep the keyboard open while as the modal is presented?
My not be the right answer but when you are dismissing the view, how are you going about this?
If you are dismissing the first responder, I'm imaging that the first responder is in fact the keyboard on the first view. Are you dismissing the keyboard and then dismissing the view or is it doing that automatically when you are dismissing the view and the keyboard belongs to the first view? Could you try and add some kind of tag to the textField's and then before dismissing the view and moving to the second view, assign the first responder to be the textField in the second view?
Sorry, can't comment yet due to reputation.
Related
I want to always display keyboard in all views in pageviewcontroller.
All views have uitextfield and I coded becomefirstresponder in viewdidload so the keyboard appears.
But problem is that when i set new viewcontroller or swipe in pageviewcontroller the keyboard disappears and re-appears.
Can I always show keyboard?
Thanks.
Go simple.. set invisible textfield (means hidden one)! Set that as a first responder basically, this text field should be in base view controller means out of page view. as soon as you swipe the page shift responder to the required text field. hence it will not disappear and appear on page shift.
UITextField resigns as first responder on any tap/swipe gesture. You need to handle it in your scrollview delegate method when you detect the scroll ended and then set the current page view controller's UITextField as first responder.
I have a question in regards to the color of the keyboard after a modal is dismissed. Basically, the flow goes like this...
I press a toolbar button on a keyboard that brings up a modal view controller.
That modal view controller dismisses itself and then calls a method on the presenting view controller that makes a text field first responder.
Here are some photos
Weirdly colored keyboard
Normal keyboard
In case it helps, I can get from the weirdly colored keyboard to the normal keyboard by pressing the shift key.
I saw this happen when I inadvertently tried to make my input field first responder twice and also when I let the system resign and re-establish first responder around my modal
I fixed the problem by manually resigning first responder before my modal was presented, and then manually becoming first responder again after my modal was dismissed.
You might just try manually resigning first responder before you present your modal.
I have two UIViewControllers, on modally presented over the other. The first controller is orientated in landscape, and the modal view is presented in portrait.
When dismissing the modal view, the view animates to reveal the landscape view below. If the keyboard is visible on the modal view at this time, it will suddenly attach itself to the left or right side of the screen to match the orientation of the soon-to-be active viewController.
Is there a way to let the keyboard disappear in the same orientation as the disappearing viewController? Or should I perhaps dismiss the keyboard before dismissing the modal view controller? In that case, what would be the best approach?
I do have an action for when the user clicks 'close'. I can there check if any objects are firstResponder, and start a timer for ~0.4 seconds before dismissing.. But it would obviously create a kind of delay that wouldn't feel all that natural.. I'd prefer a way to let the keyboard stay attached to the same orientation as the dismissing view.
This is happening:
I think the best practice would be to dismiss the keyboard before dismissing your modal ViewController. The keyboard is presented over your content and should be removed first before removing other items in the view hierarchy.
I have a viewcontroller from here I am getting a popover. From this popover i am presenting a view as modal view.
There is a textview in it. When editing begins, the entire modal view moves up (which usually people desire). But I do not want it that way.
Is there any way, i can block my modal view from moving up and down on keyboard show and hide ?
If I guessed correctly then you need to set
yourviewControler.modalPresentationStyle=UIModalPresentationPageSheet;
instead of what you are probably using right now
yourviewControler.modalPresentationStyle=UIModalPresentationFormSheet;
I have a viewcontroller from here I am getting a popover. From this popover i am presenting a view as modal view.
There is a textview in it. When editing begins, the entire modal view moves up (which usually people desire). But I do not want it that way.
Is there any way, i can block my modal view from moving up and down on keyboard show and hide ?
If I guessed correctly then you need to set
yourviewControler.modalPresentationStyle=UIModalPresentationPageSheet;
instead of what you are probably using right now
yourviewControler.modalPresentationStyle=UIModalPresentationFormSheet;