uitextfield

UITextField placeholder string is always Top aligned in ios7

一个人想着一个人 提交于 2019-12-05 16:49:19
问题 I have subclass the UITextField class and did the below code - (void)drawPlaceholderInRect:(CGRect)rect { [self.placeHolderTextColor setFill]; [self.placeholder drawInRect:rect withFont:self.placeHolderFont lineBreakMode:NSLineBreakByTruncatingTail alignment:NSTextAlignmentLeft]; } I have also written self.contentVerticalAlignment = UIControlContentVerticalAlignmentTop; line of code This placeholder text is properly center aligned in ios6 but not in ios7 it is showing top aligned. Although

QuickType predictions take key strokes into account that should be blocked by my UITextFieldDelegate

我的梦境 提交于 2019-12-05 14:27:33
I have a textField, in which I don't want to allow leading whitespace. So I implemented textField(textField:shouldChangeCharactersInRange:replacementString:) and block attempts which would change the text to something that starts with whitespace. This works as expected. Unfortunately this messes up QuickType. Each time I press space in an empty field, which is then ignored by my textField, the Quicktype text gets prefixed with this space. To be more clear, the text that QuickType will insert get's prefixed, the additional whitespace is not shown in the UI of the QuickType bar. func textField

Add Placeholder to UITextField, how to set the placeholder text programmatically in swift?

让人想犯罪 __ 提交于 2019-12-05 13:50:12
问题 I'm pulling out a phone number from a database, and when the user begins editing in the text field to change that phone number I'd like to use the number I currently have in the database as the placeholder. Since this information changes with each user, how can I set it programmatically in swift? 回答1: You need to get the phone number from your database first (convert them to String), then you set placeholder of your textField to that String, like so textField.placeholder = phoneNumberString

iOS Accessibility hide the “textField, double tap to edit” announcement

核能气质少年 提交于 2019-12-05 13:38:16
I have a textField with a pickerView as the inputView. Now when I have the voiceover on and select the textField, the voiceover will read this: "Quantity: 3 (content of the textField)", then "textField", then "Double tap to edit". Is there anyway to make the voiceover just reads the content and skip the following "textField. Double tap to edit"? I have tried to give the textField another UIAccessibilityTraits/Hints and they are not working. Thanks! Assuming your text field is a subclass of UITextField, you're looking for the static text trait. UITextField* aTextField = ..... aTextField |=

When set UITextField as FirstResponder programmatically, cause some weird actions on text editing

感情迁移 提交于 2019-12-05 12:38:37
I have a UITextField with custom keyboard, basically like a calculator. I would like my keyboard show up by default, so i used [self.topInputTextField becomeFirstResponder]; in viewDidLoad , I think that's very common usage. However, it causes some very weird actions on my textfield. When i set my textfield as the first responder in viewDidLoad, and every time after i done editing, the text will jump, and when i click another text field and and click the first text field again, the texts in the first text field sometimes shift down and disappear, but sometimes not. I feel it's very hard to

UITableView with UITextField - keep the data even after user scrolls

瘦欲@ 提交于 2019-12-05 12:24:05
I have a UITableView and it has bunch of UITableViewCells - These UITableViewCells have multiple UITextFields inside it. Now every time I scroll up and down - and the UITableViewCells go out of the view - and comes back in whatever text I enter inside the UITextField disappears - What is the best way to make this work? create an NSMutableArray which at each position, holds an NSString object which matches each cell. when you config + show each cell in - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath , set the text of the UITextField to the

How to prevent keyboard changing from Numbers to Alphabet when the space key is touched?

无人久伴 提交于 2019-12-05 11:09:09
I have UITextFields on a table to enter values. Some of these fields accept only numbers. I am using UIKeyboardTypeNumbersAndPunctuation for the keyboardType, and shouldChangeCharactersInRange to filter the characters. Also, all the corrections are disabled: textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; textField.autocorrectionType = UITextAutocorrectionTypeNo; textField.autocapitalizationType = UITextAutocapitalizationTypeNone; On the numeric only fields, when the space key is touched, the keyboard changes to Alphabet. I know that this is the default behavior. I want to ignore

Xcode 11 Beta - iOS 13 Simulator - UITextField with Placeholder getting app crash

人走茶凉 提交于 2019-12-05 11:06:52
问题 In Xcode 11 Beta Version and iOS 13 Simulator getting a crash when access TextField _placeholderLabel.textColor label key. The key used to apply placeholder text color. [textfield setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"]; "NSGenericException" - reason: "Access to UITextField's _placeholderLabel ivar is prohibited. This is an application bug" 回答1: You can do it by using runtime: add the following code to the bottom of placeholder setting Ivar ivar = class

Why doesn't the clear button aligned with the text in a UITextField?

心不动则不痛 提交于 2019-12-05 10:44:35
I have an UITextField in an UITableViewCell. For some reason the clear button isn't align to the textField's text. Here's my textField code: cell.selectionStyle = UITableViewCellSelectionStyleNone; usernameField = [[UITextField alloc] initWithFrame:CGRectMake(22, 10, cell.contentView.frame.size.width, cell.contentView.frame.size.height)]; usernameField.adjustsFontSizeToFitWidth = YES; usernameField.placeholder = @"Username"; usernameField.backgroundColor = [UIColor clearColor]; usernameField.keyboardType = UIKeyboardTypeDefault; usernameField.autocapitalizationType = UITextAutocorrectionTypeNo

Keyboard is not working proper in ios7 (Xcode 6)

心已入冬 提交于 2019-12-05 10:30:23
I have recently installed Xcode 6 in OS X Mavericks.In iOS 8 my app is working fine. But in iOS 7 sometime keyboard does not appear when i tap on textfield or textview. Any ideas? Ha cong Thuan To fix this, on simulator, open the Menu: Hardware - Keyboard - Toggle software menu (make sure it's checked) link here 来源: https://stackoverflow.com/questions/25805689/keyboard-is-not-working-proper-in-ios7-xcode-6