uitextfield

Disable button as long as several textfields are empty

白昼怎懂夜的黑 提交于 2020-01-21 19:25:27
问题 I have the following code to disable a button as long a textfield is empty: func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { let text = (textField.text! as NSString).replacingCharacters(in: range, with: string) if !text.isEmpty{ addButton.isEnabled = true } else { addButton.isEnabled = false } return true } It works fine, but now that I have 3 textfields, I want the button only to be enabled, if all textfields are

SwiftUI - State change in UITextField causes the frameWidth to grow uncontrolled and ignore bounds/frame

余生颓废 提交于 2020-01-21 18:07:07
问题 I am using SwiftUI and bridge to UITextField (I need to assign firstResponder). I use the code from here: SwiftUI: How to make TextField become first responder? The following code updates my @Binding var. This of course is intended behavior. The problem is that this causes the textField to ignore the frame/ bounds. It just expands and pushes other elements out of the view. Other parts of the view are also reliant on the @State. func textFieldDidChangeSelection(_ textField: UITextField) { text

How to change the size of blinking bar/line for specific UITextField?

天大地大妈咪最大 提交于 2020-01-21 08:49:26
问题 i'm working on a project (Swift4,Xcode 9.2) which has a feature to get text input and the blinking bar/line should be of big size (it should be Square instead of bar/line) , so i placed a UITextField for Text but i don't understand how to change the size of that blinking line/bar. So, is it possible to change the size of line/bar? and if Yes then how to do it? i know how to change the color of that line/bar but this is something different. 回答1: You can change the size by overriding the frame

How to change the size of blinking bar/line for specific UITextField?

廉价感情. 提交于 2020-01-21 08:49:13
问题 i'm working on a project (Swift4,Xcode 9.2) which has a feature to get text input and the blinking bar/line should be of big size (it should be Square instead of bar/line) , so i placed a UITextField for Text but i don't understand how to change the size of that blinking line/bar. So, is it possible to change the size of line/bar? and if Yes then how to do it? i know how to change the color of that line/bar but this is something different. 回答1: You can change the size by overriding the frame

UITextField has trailing whitespace after secureTextEntry toggle

[亡魂溺海] 提交于 2020-01-21 00:45:08
问题 I have a button that toggles between Show/Hide mode (i.e. toggles a UITextField between secureTextEntry NO and YES). The purpose of which is to allow the user to see the password they are entering. I followed the example (with the highest number of votes) here: UITextField secureTextEntry - works going from YES to NO, but changing back to YES has no effect However, when I set secureTextEntry to NO, any text that was written there ends up with a space at the end. This does not seem to be a

Typing always (force) lowercase or uppercase - ios swift

戏子无情 提交于 2020-01-20 06:58:40
问题 How to force to type always lowercase or uppercase for some textfields in swift language? 回答1: You should return false in if block because, you already updated the textfield . func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool { if textField.isEqual(textFieldBodrum) { textFieldBodrum.text = (textField.text as NSString).stringByReplacingCharactersInRange(range, withString: string.lowercaseString) return false } else if

Move specific UITextField when the Keyboard show

牧云@^-^@ 提交于 2020-01-17 08:56:20
问题 I followed the Apple documentation to move a textfield upwards when the keypad appears. The code works fine my problem is that I need that one specific textfield is moved towards the other, instead of implementing the code Apple every textfield I select is moved upwards ... How can I do to move a specific textField and not all? Thank you very much, I insert the following code used -(void)viewWillAppear:(BOOL)animated { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector

How to not allow the user to enter a value more than 190 in uitextfield?

ぃ、小莉子 提交于 2020-01-17 04:56:07
问题 I have to allow values less than 190 in uitextfield while entering itself.we should not allow user to enter 1 to 9 digits after 19 . Can anyone please provide me some info regarding this. I tried the below code.But it's allowing more than 190 . if countElements(textField.text!) + countElements(string) - range.length < 4 { var floatValue : Float = NSString(string: toString(textField.text)).floatValue return floatValue < 190.0 } 回答1: How i would do it is set the the uiviewcontroller containing

How to not allow the user to enter a value more than 190 in uitextfield?

只谈情不闲聊 提交于 2020-01-17 04:56:05
问题 I have to allow values less than 190 in uitextfield while entering itself.we should not allow user to enter 1 to 9 digits after 19 . Can anyone please provide me some info regarding this. I tried the below code.But it's allowing more than 190 . if countElements(textField.text!) + countElements(string) - range.length < 4 { var floatValue : Float = NSString(string: toString(textField.text)).floatValue return floatValue < 190.0 } 回答1: How i would do it is set the the uiviewcontroller containing

Xcode UITextField limit type of characters

被刻印的时光 ゝ 提交于 2020-01-16 18:12:49
问题 in Xcode, how can I limit the character of UITextField with "ABCD1234567", the first 4 chars is the alphabet with no special char and the rest must has 6 or 7 number. Please help me to solve this. Thanks for advance. 回答1: Define the following variables #define NUMBERS @"0123456789" #define ALPHABATES @"ABCDEFGHIJKLMNOPQRSTUVWXYZ" Now in the delegate function of the textfield, - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *