2

I'm trying to hide the iPad keyboard on a modal view, which has the FormSheet style. I tried to resignFirstResponder, but nothing happens. Is this a bug or doesn't this work at all?

best regards

EDIT

-(void)hideKeyboards 
{
 [emailField resignFirstResponder];
 [passwordField resignFirstResponder];
 [confirmPasswordField resignFirstResponder];
} 

-(IBAction)emailFieldDone:(id)sender
{
 [self hideKeyboards];
} 

-(IBAction)passwordFieldDone:(id)sender
{
 [self hideKeyboards];
} 

-(IBAction)confirmPasswordFieldDone:(id)sender
{ 
 [self hideKeyboards];
} 
Master Stroke
  • 5,108
  • 2
  • 26
  • 57
Lukas
  • 1,346
  • 7
  • 24
  • 49
  • have you set delegate in .h file? – kb920 Nov 06 '12 at 11:30
  • That's what i tried: -(void)hideKeyboards { [emailField resignFirstResponder]; [passwordField resignFirstResponder]; [confirmPasswordField resignFirstResponder]; } -(IBAction)emailFieldDone:(id)sender { [self hideKeyboards]; } -(IBAction)passwordFieldDone:(id)sender { [self hideKeyboards]; } -(IBAction)confirmPasswordFieldDone:(id)sender { [self hideKeyboards]; } – Lukas Nov 06 '12 at 11:31
  • check have you set delegate to text fields in your xib or set textfield.delegate = self; – P.J Nov 06 '12 at 11:34
  • Yes, the delegates are set correctly. It works on iPhone, but not on iPad .. am i missing something? – Lukas Nov 06 '12 at 11:35

3 Answers3

3

Overriding disablesAutomaticKeyboardDismissal to return NO as below fixed the same problem of mine. You need to override disablesAutomaticKeyboardDismissal of UINavigationController, not the own view controller, to fix this issue. Maybe use a category is a good idea:

- (BOOL)disablesAutomaticKeyboardDismissal {
    return NO;
}

Also, check this iPad keyboard will not dismiss if modal view controller presentation style is UIModalPresentationFormSheet question if you want to get a detailed explanation.

Community
  • 1
  • 1
sunkehappy
  • 8,970
  • 5
  • 44
  • 65
  • You need to override disablesAutomaticKeyboardDismissal of UINavigationController, not the own view controller. – sunkehappy Nov 07 '12 at 02:54
  • Hello, i subclassed the navigationcontroller and override the disablesAut. method, but it doesn't work at all. – Lukas Nov 07 '12 at 09:00
  • Can you paste out your code? This should work. So many people have used this to solve their problem. Check the link there are other ways to solve this problem. Try them. – sunkehappy Nov 07 '12 at 09:22
  • I created a class called customNavigationController and pasted your code in it. I applied this custom class to my navigationcontroller. Then i tired the resignFirstResponder thing again, but that didn't work. The keyboard won't hide. :( – Lukas Nov 07 '12 at 09:57
  • AHHHHHHHHHHHHHHHH! I hate myself... Your solution works perfectly!! The problem was that i am pushing to a view, which has a becomeFirstResponder to a textfield inside of it :) So it disapears and appears right after it dissapeared... :) THANK's! – Lukas Nov 07 '12 at 12:20
2

try this if you are using textview

 Textviewobjectname.editable = NO;
Master Stroke
  • 5,108
  • 2
  • 26
  • 57
0

Set delegates to all text field

  textField.delegate=self;
NANNAV
  • 4,875
  • 4
  • 32
  • 50