I am using the following tutorial to show the uitextfield above the keyboard at all times:
http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-keeping-content-from-underneath-the-keyboard/
But the problem is the uitextfield only gets shown above the keyboard if the person starts typing into the field, but not if the cursor is in the textfield.
How can I change it so that the uitextfield gets shown above the keyboard once the cursor is in the UITextField?
Thanks
Check UITextFieldDelegate and select appropriate method.
In this tutorial they use textFieldDidBeginEditing method to assign active textfield.
As it clear from method name, it executes when someone start typing in text field.
I downloaded the sample code and work just fine for me. The only thing that I figured you could misunderstood is in the case the keyboard it's already below the textField, in these cases the view will not scroll.
I hope this helps. If it's not this that you want, please tell me more about it.
Related
I want to present emoji panel and using NSApp.orderFrontCharacterPalette(nil). it works fine, but sometimes it appears at random place and i want it to be "constrained" to text field where I'm going to use it. Can i set frame of panel manually or do it in another way? thanks for help
It requires your text field to be the first responder.
You could make a text field the first responder by calling following method:
Swift:
textField.window?.makeFirstResponder(textField)
Objective-C:
[[textField window] makeFirstResponder:textField];
Hope it helps.
The clear button of UITextField gets hidden in iOS 9, it was working perfectly till now in all other iOS versions. I tried out everything from the below links :
(1). UITextField Clear Button Does Not Show
(2). How to change the tint color of the clear button on a UITextField
(3). UITextField clearButtonMode color
The button does not show up till we hover the mouse over its position.
In storyboard, I have selected "appears while editing" option and even tried "is always visible" option, but still the same.
I don't want to create custom button, so please let me know is there anything wrong in iOS 9 or what else can be done to resolve.
Waiting for a positive reply.
Thanks !!
Check the property for the specific button, textfield where you have declared, whether you had mentioned property as "Weak". If at all you have mentioned as weak please change it to "Strong".
I want to show a clear button always in a UITextField. I have tried to both set this in .xib Interface Builder:
and in code using this line: [_firstNameField setClearButtonMode:UITextFieldViewModeAlways];
Neither causes the button to show. Help please.
When you set it to UITextFieldViewModeAlways the clear button appears as long as there is text on the UITextField.
Hope this helps!
I made a research and all posts here are very blury regarding this issue.
I would like to use a UIPicker when pressing on a UITextField.
I would realy appriciate a step by step guide.
I tryd all posts here but every post gives me only a portion of what I need and I can't seem to connect it all together.
This is the last part of my application and i'm going crazy to finish it..
Thank you in advanced!
Gal
There is an inputAccessoryView property that contains a view that will appear instead of a keyboard on the bottom of the screen. Create a UIPicker, adjust its frame, provide values and assign it to the inputAccessoryView property.
UIPicker will appear when user taps on your UITextField.
If you don't need editing, you may use a UILabel instead of the UITextField. Solution is the same. I have a ready-made class if you need.
Here's a way:
http://www.youtube.com/watch?v=t_F1ex5opgA&t=14m10s
-(BOOL)textfieldShouldBeginEditing:(UITextField *)textField
where textField is the name of your text field.
Call your UIPickerView and return NO so that your picker is loaded rather than the keyboard.
The idea is to call an action that opens the UIPicker when the user taps the UITextField. Because the UITextField does not responde to the usual touchUpInside events that UIButtons respond to, I would just overlay a transparent UIButton on top of the UITextField and just in case, make the text field's userInteractionEnabled property NO. Hook the UIButton to responde to touchUpInside and call a method that opens the UIPicker. Another option would be an immediate response to the text field's touch by implementing "textFieldShouldBeginEditing" and immediately resigning the text field.
The next step would be to present the UIPicker - if we are talking about iPad, this would best be done by using a UIPopoverController. On iPhone, maybe consider bringing it up modally. When you create the view controller that holds this UIPicker, be sure to add a delegate property to it so that whatever value that was selected on the picker can be transfered back to the main view controller and on to the UITextField.
Hope this helps with getting you started.
I have a simple UITextField called month where I get users to simply enter the month they want via the keyboard that comes up. I would now like it for them to be able to use a UIPickerDate (or UIPicker) to make this selection instead. So when they press on the text field, a mini UIPicker appears and they make there selection, press anywhere on the screen and the picker disappears.
Does anyone know how to do this or has any suggestions? I am pretty new to programming and have looked at other answers but everyone seems to be referring to this being done in a table.
Thanks in advance!
You can set the inputView property on the UITextField to be an instance of UIDatePicker. When the instance of UITextField becomes the first responder, the picker view will be displayed with the standard keyboard animation.
// Assume that self.monthTextField and self.datePicker
// are properties of the view controller class
self.monthTextField.inputView = self.datePicker;
As for dismissing, that depends on the context. If there are more text fields to populate, consider adding a UIToolbar as the inputAccessoryView of self.monthTextField. Then you can add something like a UIBarButtonItem to make the next text field the first responder, similar to how the standard keyboard provides a Next button.