iOS keyboard won't dismiss after view dissappears - ios

I have been looking for a similar questions but so far the answer doesn't fit my purposes. I have a UITableViewController inside A UINavigationController with custom UITableViewCells containing textfields inside. When I click on the textfields they become the firstResponders and when I click return they resign it. So far so good.
My problem is one of these cells is performs a Submit function. After this is done whenever I press the textfields the return button doesn't dismiss the keyboard anymore.
My question is, since I'm not releasing anything, why do these textfields stop listening to the resignfirstresponder message?
UPDATE: I finally got this working by setting an UITextfield ivar in the class, making it the first responder whenever the textfield begins editing in :
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
[textField setTextColor:[UIColor blueColor]];
focusedTextField = textField;
}
And calling [focusedTextField endEditing:YES]; when i press the submit button. Just added this after seeing some answer in SO, but I can't remember the link, sorry.
Hope it helps.

If you have declared a method for return(let's say your textfiled is called textField) use this code in your method;
[textField setUserInteractionEnabled:NO];//but this may restric you if you need to use it again
But if you use standard return property of the keyboard it may be something related to Apple's restrictions

Related

UITextField and UIButton are not clickable

I am implementing simple UI for URL checking. For this, I used textField and button objects.
When I run the program first time, textField and button will work fine but when I click on the done button on the keyboard then the keyboard is dismissed. Now I want to edit the textField and when I am trying to click on textField it is not clickable or not showing the keyboard. same thing happened to the button, next button is also not clickable.
Here is the code I wrote for the button action
- (IBAction)urlNextButtonAction:(id)sender {
[self.urlTextfield resignFirstResponder];
[SVProgressHUD showWithStatus:#"Verifying URL"];
[self URLValidationMethod];
}
Please check this video you will understand the problem very easily
This is the ViewController screenshot from storyboard
There could be several issue with this..
Check either Textfield delegate might not be or properly set.
Try to debug textfield delegate methods are they working.
it would be helpful if you show what you have written in keyboardShouldReturn method.
It seems like the problem is with the SVProgressHud. You should remove it as soon as you task is completed by calling [SVProgressHud dismiss] or else it will block the UI.

Is there a way to know that iOS keyboard is really hidden (dismissed by user)?

I need a way to detect the case when user dismisses iOS keyboard manually, using "keyboard" button on keyboard. I tried to use UIKeyboardDidHideNotification, but quickly discovered that this event is also fired when user splits the keyboard, leaving it on screen.
Is there a way to know for sure that keyboard was really hidden?
To get solution I had to slightly modify my original implementation: I've replaced assigning nil to inputView member of my main view with creating and destroying custom invisible UIView<UIKeyInput> view to show and hide keyboard correspondingly. This allowed me to override this view's resignFirstResponder method which is always called on keyboard resigning - either in normal or in split state, when user dismisses keyboard using special button or when I remove it programmatically.
I believe that UIKeyboardDidHideNotification is only sent when the keyboard is truly gone. From the Apple docs:
Posted immediately after the dismissal of the keyboard.
However, you could also look to see if any of your inputs are currently the first responder:
BOOL keyboardUp = NO;
for (UIView *view in self.textInputs)
{
if (view.isFirstResponder)
{
keyboardUp = YES;
break;
}
}

Click a button to show the keyboard iOS

I want to realize the function: when I click a button, a interface of keyboard will come out in a dependent interface. How can I do it? Just for iOS.
You need to add to your current view UITextField with frame = CGRectZero, create a reference to that textField in code and then on pressing button call becomeFirstResponder on textField.
You need to add an UITextField to your view and call then [myTextfield becomeFirstResponder]; Its possible to set the hidden attrribute from UITextField to YES - so the user will never see the textfield. After Keyboard input is finished you can remove the UITextField with removeFromSuperview.
Maybe a little bit dirty,but thats the solution I used often. I wonder if the SDK provide another possibility.

How to disable keyboard but enable UITextFields when using UIDatePicker?

This one is kind of hard to explain, so ask any questions you need to clarify the question. I have an iPad app (XCode 4.2, iOS 6, ARC and Storyboards).
In this app, I have a UIPopover that contains a UIView with two (2) UITextFields in it and a UIDatePicker. (see image). When I go to that scene, I have unchecked userInteractionEnabled on both textFields to prevent the keyboard from responding, which works, but doesn't allow the other UITextField to be accessed after the first one. I tried [oFinishTime setInputView:oTimePicker]; but it takes the timepicker and moves it outside of the popover, which is unacceptable.
I have touchUpInside events "wired" for each of the textFields, but neither one gets called when tapped due to UserInteractionEnabled being unchecked. I could remedy this whole thing if I could have it enabled and set a flag in the action event.
How can I enable both UITextFields yet prevent the keyboard from showing? I will be happy to post any relevant code you need to see.
May be I did not understand your problem correctly , but it seems like you all you are trying to do is Open a picker on tap and display the value set in UIPicker. You are not really using any functionality of a UItextField. A label or a button might serve the same purpose and save you from doing the extra work of disabling the keyboard.
In any case if you want to use textfield and disable keyboard picker appearing as the input view and have your own input view to it, you could do
-(void)textFieldDidBeginEditing:(UITextField *)textField{
[textField resignFirstResponder];
}
You could take a look at this:
Display datepicker on tapping on textfield
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField; // return NO to disallow editing.
assign delegate for each textfield and in the delegate method verify if its the one which should open picker instead of keyboard.
If it is the one then return NO
else YES
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
if (textfield == startTimeTextField)
{
[self openPicker];
return NO;
}
return YES;
}

UITextField not getting keyboard input

I'm having troubles entering text into an UITextField under a SVProgressHUD (Basically an UIView with a full-screen transparent UIWindow and some UIView subviews showing text and a custom-drawn progress bar).
My problem is that the UITextField displays the blinking cursor and the keyboard shows, but when I tap a key, nothing is entered into the text field.
I only see that the cursor's blinking interrupts just like normal.
Interestingly enough, the back (delete) key works (it really deletes the last letter in the UITextView), but not any other key.
I'm using iOS 6.
Any help would be highly appreciated.
EDIT:
The same UITextField works fine when there's no SVProgressHUD displayed. This makes me think it has something to do with the first responder, but I have already tried calling resignFirstResponder on every window and subview of the SVProgressHUD and it still does not work.
I finally found the problem:
SVProgressHUD calls makeKeyAndVisible when it's initialized, because it wants to receive keyboard notifications for repositioning. I looked up what the "Key Window" actually is and found out:
...The key window responds to user input...
Now, as the UIWindow of the SVProgressHUD was the keyWindow, my other window, which contained the UITextField did not get the user input.
I finally call makeKeyWindow on the AppDelegate's window and everything is working fine.
I hope this helps anyone with similar problems.
Call resignFirstResponder() to dismiss the keyboard before showing SVProgressHUD.
Have you implemented the method....
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
...to filter out any unwanted characters? If so, perhaps it's being a little overzealous with the filtering?
For me this is worked.
I did changes in my textfield delegate method then it worked.
if ([textField isEqual:selectBankName])
{
return No;
}
else if ([textField isEqual:enterAmountTextfield])
{
return YES;
}
return NO;
}
set delegate for textfield
Make sure textfield userInteraction is Enabled.And
Finally Please check your textfield delegate method.

Resources