iPhone app.
I have a simple view with UITextView as first responder. I resign first responder and pop to the previous controller but the keyboard stays. Textview doesn't even exist anymore but the keyboard is still visible.
The controller that I pop to is a tableview, no objects that can even assume first responder status. So the keyboard is just there obscuring half my table and there is not even a way to dismiss it. I have to navigate back to a view that has a text box or textview, select one and dismiss that in order to get rid of the keyboard.
How is this possible?
On viewWillAppear just write
[self.view endEditing:YES];
Related
My app starts on login screen. After that I use the next code to call the TabBarViewController
DMMainScreenViewController *mainScreenController = [[[DMMainScreenViewController alloc] initWithNibName:#"DMMainScreenViewController" bundle:nil] autorelease];
self.view.window.rootViewController = mainScreenController;
[self.view.window makeKeyAndVisible];
and then I move to the last tab by clicking on that.
There are 2 UITextField and one UITextView and then when I touch any of them the keyboard is not showing up and I can not also change to another TextField/TextView but I can move to another tab.
How can I fix that?
Thanks.
keyboard to show up immediately you'll need to set the text field as the first responder using the following line:
[textField becomeFirstResponder];
but in these case of tabbarViewController, as tonklon says in his answer:
If the tabbar is needed while the keyboard is visible you could only
move the tabbar above the keyboard, or resize the tabbarcontroller, so
that the tabbar remains visible.
Are you sure you need the tabbar while the keyboard is visible?
Remember a tabbar is for changing the view. Perhaps you need to
rethink your interaction design.
Are you using IB to create your views? If so, did you remember to wire up your UITextField to the File's owner so that view knows where to send the notifications that you clicked on your TextField?
Is there any way to keep a UITextField first responder even as I push another view controller?
Essentially, I'm taking a screenshot of the screen, using that screenshot in the new view controller, and then popping the second view controller. The issue, though, is that it isn't a smooth transition; when the view controller pops, the keyboard in the picture disappears (since the picture was in the second view controller but has since been popped), but the actual keyboard hasn't reappeared yet. You see the keyboard sliding up just after the picture disappears. Is there anyway to prevent this such that the keyboard is just always there?
I don't have any other UITextFields in the new view controller, only the screenshot, a UIButton, UIScrollView, and two UIGestureRecognizers.
Thanks in advance!
I'm trying to resign the keyboard when user clicks a UIButton, which triggers a new content view (of type UIViewController).
This 'compute' button is at the end of list of several textfield inputs which the user scrolls through for entry; there's no need to resign the keyboard in this view. The scrollview also accommodates resizing when the keyboard is activated.
However, I notice that when proceeding to the next view, upon button click, and then returning to this view of textfields, via the back button on the navigationbar, the keyboard remained up, and this view no longer scrolls the additional area occupied by the keyboard.
My idea is to dismiss the keyboard when the view changes, so when the view returns, any input will trigger keyboard notification and adjust the scroll view accordingly (which is working).
Thank you so much,
Something like this might get you going in the right direction:
- (void)viewWillDisappear:(BOOL)animated {
/* Dismisses the keyboard whenever the view disappears
*/
[self.view endEditing:YES];
[super viewWillDisappear:animated];
}
You could also put that endEditing call in the action handler for the "compute" button you mention.
I have a search display controller. If the user scrolls the table view of the search display controller after entering text into the search text field, the keyboard disappears because the search display controller is resigning first responder. Is there a way to keep the keyboard there while scrolling is occurring?
Give your UISearchBar a delegate (perhaps the same object that is the delegate of your UISearchDisplayController) and implement searchBarShouldEndEditing: to return NO in the circumstances that you do not want it to resign (for example, when mySearchDispController.searchResultsTableView.dragging is YES).
I recently discovered that if a UITextField is being edited in a controller that's attached to a UINavigationController and the back button is pressed, upon returning to this controller, the DidBeginEditing function is called again and the UITextField keyboard is brought back up. I was wondering if there's a way to stop the keyboard from coming back up. Maybe there's a way to hook the back button so it doesn't save the fact that the text field is being edited.
Implement viewWillDisappear: on the view controller that controls the text field, and call:
[theTextField resignFirstResponder];
This will dismiss the keyboard.