uitextfield

textFieldDidBeginEditing: for more than one textfield

自古美人都是妖i 提交于 2019-12-05 01:30:50
I am fairly new to iphone programming and here I am facing some issues. Now in my application, I have two textfields and I want to fire an event while second textfield starts editing. now I am using following function - (void)textFieldDidBeginEditing:(UITextField *)textField but the thing is the event is being fired when the first textfield starts editing. It does not wait for the second text field. Is there any way I can use this function for the second textfield or may be somehow could know and pass it the value of the active textfield? I tried writing the name of the textfield instead of

How to stop my Custom Keyboard from 'floating' or being undocked on iPad

旧巷老猫 提交于 2019-12-05 00:59:21
I have a custom Keyboard that gets displayed for a certain UITextField when I set the textField's inputView to my KeyboardView. The keyboard works fantastically well but it has become apparent that the keyboard will 'float' if the user has previously undocked the built in Apple Keyboard or indeed split it. I have searched for many hours for a way to ensure my custom keyboard does not act like this and instead stays docked to the bottom of the screen regardless as to whether the user has previously undocked the built in Apple Keyboard. self.keyboardInputView = [[[KeyboardInputViewController

Text jumps when animating position of UITextField subclass

馋奶兔 提交于 2019-12-04 23:49:42
When I animate the location of my UITextField subclass, the text in the field jumps out of step with the location of the UITextField holding it, which is very jarring and I can't figure out why it happens: My subclass adds a button to the right hand side of the text field that when tapped calls a method on the view controller, which changes the textfield border colour and moves the text field up the screen by changing the top space constraint of the text field, and a couple of other views located above it. [UIView animateWithDuration:0.3 animations:^{ self.tableViewBottomSpaceConstraint

Can't type text into UITextField or UITextView in iOS6

夙愿已清 提交于 2019-12-04 22:38:49
In one of my apps, when I try to edit (type some text) UITextField , UITextView or any other 'text-able' UIControl the cursor just blinks but no characters are typed in except BACKSPACE (possible only when I have some initial text in it), RETURN and switching character types. This goes to all controls across whole application. Summary: It happens only from iOS 6.0 (does not occur on iOS 5.x, 4.x neither Simulator or real device) All delegate methods are fired (shouldBeginEditing: didBeginEditing:) except shouldChangeCharactersInRange: isFirstResponder flag is behaving set correctly

iPhone perform action when UITextField / UISearchBar's clear button is pressed

冷暖自知 提交于 2019-12-04 22:37:14
Is it possible to gain access to a delegate method that will allow additional actions to be performed when the "clear" button is pressed on a UITextField / UISearchBar? Thanks See: UITextFieldDelegate Protocol Reference If you set your view controller as the delegate for your text field (can be done in interface builder), you can use: - (void)clearSearchTextField { ... } - (BOOL)textFieldShouldClear:(UITextField *)textField { if (textField == self.searchTextField) [self clearSearchTextField]; return YES; } For Swift 3: To perform an action when the "clear" button is pressed on a UITextField

How to change all TextField border colour in Swift 3

微笑、不失礼 提交于 2019-12-04 21:47:07
How to change all TextField border colour in Swift 3 i build one iPad application. i have many TextField in my .xib file and now i want to change border colour but it so many line to write particular textfield so any sort way for this ? Add this extension to create border for all textfields in your project. extension UITextField { open override func draw(_ rect: CGRect) { self.layer.cornerRadius = 3.0 self.layer.borderWidth = 1.0 self.layer.borderColor = UIColor.lightGray.cgColor self.layer.masksToBounds = true } } extension UITextField { func cornerRadius(value: CGFloat) { self.layer

Validate Textfield after each character entered

六月ゝ 毕业季﹏ 提交于 2019-12-04 21:12:27
I have searched for an answer but cant find an answer related to this. I am trying to validate every input into a textfield but not sure how to go about it, the idea is to check a username exist on a server so I would assume I need to post to the server each time something is entered and if success do whatever. Could someone please advise I would be grateful. You can use addTarget:action:forControlEvents: with UIControlEventValueChanged (e.g: [textfield addTarget:self action:@selector(usernameChanged:) forControlEvents:UIControlEventValueChanged ). This will inform you AFTER the text changes

Blur effect - Background UITextField

点点圈 提交于 2019-12-04 21:10:28
I use Swift 2 and Xcode 7. I would like to blur in the background of my UITextField. I have not found a property backgroundView . Only background (for background image) or backgroundColor . I would have come to add a view in background. But I do not know how to make a UITextField. Do you have a solution ? You can only add some kind of view to make it a blur view. Now the problem is that textfields don't have a backgroundView property but they do have a background property where we can set an UIImage . So we can make a UIImage from a UIView too This method will create a UIImage for the UIView

Custom Keyboard Set Cursor Position

爷,独闯天下 提交于 2019-12-04 20:37:06
I have a text field tapping on which a custom keyboard appears containing numbers 0-9 and a backspace button. I'm able to delete text at the end as well as from middle of string. But when i delete text from somewhere middle, the cursor jumps to end position. I want cursor to remain at same position where it was while deleting text. Please reply ASAP and thanks in advance. Cyrus1 First get the initial position of the cursor (or the end of the selected range): UITextRange *selectedRange = [textField selectedTextRange]; NSInteger offset = [textField offsetFromPosition:textField.endOfDocument

How to figure out the current caret position in a UITextField?

删除回忆录丶 提交于 2019-12-04 20:36:47
I want to programmatically paste a string into a text field or text view at the current caret position. Is there an easy way to do this? I would need to know the current caret position, but there's no method to retrieve it, right? Don't want to call private API. Is there any legal way to do it? Use UITextView 's selectedRange method. If the range has a non-zero length (in the case of the user having selected some text), just take the location (or NSMaxRange() , or replace the entire range...) Instead of pasting option. Get the string from textfield or textview insert the string which you want