Keyboard won't dismiss when popover closes on iOS 3.2 - iphone

- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController {
[self dismissFirstResponder];
return YES;
}
-(void)dismissFirstResponder {
[nameField resignFirstResponder];
[descriptionField resignFirstResponder];
[helpField resignFirstResponder];
}
I have tried loads of different things, but the keyboard just isn't going down:
I checked to see if my outlets were hooked up correctly in Interface Builder
I put breakpoints inside the 2 methods to check they were being called at the appropriate times, and they were. Those 3 Text Fields are the only ones in the app.
What happens: The popover gets dismissed but the keyboard stays up.
I would really appreciate some help on this matter. It might be a known bug on iOS 3.2, if so any workarounds would be gratefully accepted. Thanks

Make sure the delegate for UITextView the UITextField is assigned
Then call the following method to dismiss any keyboard activity from the view.
[self.view endEditing:YES];

Related

Weird keyboard behavior in my iOS app

Ok, so here's how my keyboard behaves:
There's a button which calls a method to send a textmessage, that works fine. If the user now sends the text everything's fine.
Now if (s)he taps cancel it switches back to my view (as it's supposed to do), but the keyboard won't show up. I already tried
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
[self dismissModalViewControllerAnimated:YES];
[inputView becomeFirstResponder];
}
since it didn't work I tried:
-(void)viewDidAppear:(BOOL)animated{
[inputView becomeFirstResponder];
}
but that won't work either. So how can I get my keyboard to show up?
EDIT: inputText is an UITextView.
This might be related to sending YES in dismissModalViewControllerAnimated:. When animations are involved, statements generally don't remain synchronous. So, your call to [inputView becomeFirstResponder] must be executing before the modal dialog has been dismissed, resulting in an inconsistent state. This is the reason why the inputView does not take focus.
HTH,
Akshay

resignFirstResponder makes field lose focus but keyboard doesn't disappear

I call resignFirstResponder for my textField, it returns YES, but the keyboard does not disappear. I tried many variations and tips, but nothing helped.
May have an idea why this is possible?
I repeat, the method works, the field loses focus, but the keyboard does not disappear
I use iOS 4.3.
UPD:
if([self.securedTextView.passField isFirstResponder]){
if([self.securedTextView.passField canResignFirstResponder]){
[self.securedTextView.passField resignFirstResponder];
}
}
and [self.securedTextView.passField resignFirstResponder]; returns YES, but the keyboard is still on the screen...
you can use UITextField delegate methods explained below..and Try using this..
-(BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}
Happy Coding...

How can one move to a new screen after clicking done on the iPhone keyboard?

I'm a new iPhone developer, so I'd really appreciate some guidance.
I've started off with something...but I don't know what to do from there.
- (BOOL) textFieldShouldReturn:(UITextField *)textField {
//hide keyboard
[textField resignFirstResponder];
//after hiding the keyboard, call another method
//which should display a UITableView
return YES;
}
Please let me know if I can provide more information.
Take a look the Apple developer documentation that cover the topics of ViewControllers and navigation.
This should get you started.
http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html

MFMailComposeViewController Keyboard Issue

How do i dismiss the keyboard without pressing the Send or Cancel button in MFMailComposeViewController?!
Thanks for any help.
Can you try this.
UIWindow* keyWindow = [[UIApplication sharedApplication] keyWindow];
UIView* firstResponder = [keyWindow performSelector:#selector(firstResponder)];
[firstResponder resignFirstResponder];
hope this helps....
I experienced a similar problem: For some reason iOS does not dismiss the Keyboard of a MFMailComposeViewController when the application enters background (the dismiss happens when the application becomes active again). However iOS dismisses the keyboard if the first responder is a simple element (e.g. textview). Calling resignFirstResponder did not work for me in this particular case.
Because I switch windows on applicationBecomeActive (to show a login screen) I ended up having multiple keyboards above each other (the one on the top not working).
I found a simple workaround to dismiss the keyboard of an MFMailComposeViewController when the application resigns active:
- (void)applicationWillResignActive:(UIApplication *)application
{
// Workaround: MFMailComposeViewController does not dismiss keyboard when application enters background
UITextView *dummyTextView = [[UITextView alloc] init];
[self.window.rootViewController.presentedViewController.view addSubview:dummyTextView];
[dummyTextView becomeFirstResponder];
[dummyTextView resignFirstResponder];
[dummyTextView removeFromSuperview];
// End of workaround
}
This will implicitly resign the first responder if we have any viewController that is currently beeing presented.
While you probably can do it by finding whichever view is the first responder and calling resignFirstResponder on it (unless you're on iPad and MFMailComposeViewController uses UIModalPresentationFormSheet), Apple might reject your app for it. Quoth the documentation:
Important: The mail composition interface itself is not customizable and must not be modified by your application.
This could easily be construed to include the behavior of the keyboard.

UITextField resign first responder iOS4

I have a simple piece of code that works on every system except iOS4.
It's about resigning first responder for a UITextField. The text field is all wired up, and here's the code for the delegate:
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
[opis resignFirstResponder];
return YES;
}
I've tried it almost every possible way, trying to return NO as well and it doesn't work. The weirdest thing is that it DOES work on every iphone OS before 4.0 and on iPad as well (tested in simulators and on actual devices)
Can anyone help?
This worked with my 3GS in iOS4. Are you sure you properly set the UITextField delegate?
- (BOOL) textFieldShouldReturn:(UITextField*)textField {
[textField resignFirstResponder];
return YES;
}
Not sure if this is similar to your case, but I have a UITextField in a UIAlertView and HAD a similar problem with keyboard not dismissing on resignFirstResponder.
Here was my solution:
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
[alert resignFirstResponder];
return YES;
}
It seems that the alert became firstResponder after textfield resigned.
This is a very classic problem. I assume you are setting the delegate to your textField but the question is where? Are you setting in the initWithNib... initializer of your controller? Than that is wrong. Because your text field is not initialized by then. Its initialize in viewDidLoad method, so you should set your delegate there and it should work.