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.
Related
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.
I am hoping if someone can help me resolve an IOS/XCode question.
I need to have a UITextView created inside a UITableViewCell, this UITextView has responds to a user click, upon which a UIPopoverController will be displayed so that a sub-UITableView is displayed (inside the UIPopoverController) allowing a user to select from a list of choices (lines of text). After the user select the choice (one of the line of text), that line of text will then be displayed inside the said UITextView. First problem I am having is that when the user click on the UITextView the keyboard gets displayed instead of the UIPopoverController. How do I go about disabling ie. calling resignFirstResponder so that instead of the keyboard displaying, I get the UIPopoverController coming up instead. Would someone be kind enough to share similar codes? or point me to some sample of how this can be done? Thanks so much in advance.
You can use following delegate method to detect when textView is tapped and show your popOverController accordingly, return 'NO' in the delegate method so that no keyboard will appear...
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
// code to show popOverController
return NO;
}
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.
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
How can I dismiss the keyboard when the user clicks a button?
A short example for a better understanding: the user edits some text in some textfields and at the end he doesn't click "Done" or smething else on the keyboard, but he clicks on an button "Save" while the keyboard is still shown. So, how can I now dismiss the keyboard?
Thx. Regards, Daniel
You can also call [view endEditing:YES] on any view above the text field in the hierarchy. This is useful if you aren't sure which text field has first responder status. It also optionally lets a text field delegate stop the action (by returning NO from shouldEndEditing:) which is nice if you are using a delegate to do validation on the fields.
in button action write,
if([textField isFirstResponder]){
[textField resignFirstResponder];
}
if there are more textfields get the current textfield reference everytime while editing started, and resign its responder in button action.
If you have multiple text fields and don't know which one is first responder (or you simply don't have access to the text fields from wherever you are writing this code) you can call endEditing: on the parent view containing the text fields.
In Swift, in the related view controller, add this line to the button function:
self.view endEditing(true)
In addition to SriPriya's answer, please have here the Swift 2 styled version:
if numberTextField.isFirstResponder() {
numberTextField.resignFirstResponder()
}
Please enjoy...