uitextfield

Disable blinking cursor from UITextField in swift?

社会主义新天地 提交于 2019-12-21 03:51:36
问题 How to disable cursor in Swift from UITextField ? Condition - When the user logs in, then enter into application. If user can may me logout from application then not show cursor into UITextField. 回答1: First you need to confirm to UITextFieldDelegate and then set you textField like yourTextField.delegate =self add yourTextField.resignFirstResponder() to your code. Call resignFirstResponder to yourTextField. and you can also use below code (According to your need). In delegate method

How to determine the length of the text in a UITextfield

本秂侑毒 提交于 2019-12-21 03:36:15
问题 I have a UITextField from which I'd like to determine the width of the entered text. The bounds property has just the size of the Textfield but not of the text 回答1: CGFloat width = [aTextField.text sizeWithFont:aTextField.font].width; 回答2: Now that sizeWithFont: is deprecated in iOS 7.0 use CGFloat width = [tf.text sizeWithAttributes: @{NSFontAttributeName:tf.font}].width; https://developer.apple.com/library/ios/documentation/UIKit/Reference/NSString_UIKit_Additions/#//apple_ref/occ/instm

Delete all characters after a certain character from a string in Swift [duplicate]

天涯浪子 提交于 2019-12-21 03:34:18
问题 This question already has answers here : What is the more elegant way to remove all characters after specific character in the String object in Swift (4 answers) Closed 3 years ago . I have a textField and I would like to remove all character after a certain character. For instance if what I have in the textField is the word Orange and I want to remove all characters after the n I would like to get Ora after the deletion. How can I delete all characters after a certain character from a string

How do you create textfield padding in Swift 4?

徘徊边缘 提交于 2019-12-21 01:06:20
问题 I have a textfield called nameTextField I rounded the corners with the nameTexfield.layer.cornerRadius = 5 Now, the text within the textfield is touching the left side. I want to create padding between the text and border. Every post I find uses cgRect, but Swift no longer supports that. Please provide the correct code if you can figure it out and please explain the answer if you can. I appreciate the help! I also need to know where to put the code if there is any. 回答1: As @the4kman says,

IOS: action with enter key of iPad KeyBoard

怎甘沉沦 提交于 2019-12-20 17:35:07
问题 I have two textfield, in first textfield I write "Hello" and when I push enter in iPad keyboard, I want that in second textfield appear "World"; How can I use enter to create an action in my application? 回答1: You would typically assign your view controller as the text field's delegate and then implement the textFieldShouldReturn: method, e.g.: - (BOOL)textFieldShouldReturn:(UITextField *)textField { otherTextField.text = @"World" return YES; } 回答2: You can do that by implementing the

UITextView's inputView on iOS 7

我们两清 提交于 2019-12-20 14:23:22
问题 I'm trying to create a custom keyboard for a UITextField, the background of this inputView should be transparent, I have set the background color in the view's xib file to "clear color". It is working great on iOS 6 and earlier.. but on iOS 7 it not working Any idea how can I make it work? I want it to be fully transparent 回答1: This will set the backdrops opacity to zero when displaying your custom keyboard and reset it back to 1 when the normal keyboard is shown. + (void

Xcode won't show my textfield placeholder text in storyboard

痴心易碎 提交于 2019-12-20 11:15:49
问题 When I assign my textfield's placeholder value in the attributes inspector, it won't show in the storyboard, however, when I run a simulator of the application is is there. Is there a setting I'm missing? I just want to be able to see the placeholder text in the editor. Below is a screenshot of xcode and one of the simulator 回答1: I am having the same issue, fortunately I run a MacBook with Xcode 9.1(9B55) and an iMac with Xcode 9.2(9C40b) On my MacBook all placeholders show up but on iMac

UITableViewController not scrolling view when keyboard appears

…衆ロ難τιáo~ 提交于 2019-12-20 10:33:39
问题 I have a UITableViewController with around 20 static cells, some of these cells have UITextField s within them and some are just for selecting with a checkmark. The table is about 1.5 views worth so scrolling is required to get at the lower text fields. When I click within a textfield at the bottom of the table the keyboard pops up as it should but this then appears over the cell/textfield. I was under the impression (From Apple docs and elsewhere) that the UITableViewController class handles

How to set focus to a textfield in iphone? [closed]

我与影子孤独终老i 提交于 2019-12-20 09:46:55
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 8 years ago . How do you programmatically set focus to some textfield in iPhone as the result of pressing on the textfield? 回答1: Just make the textField firstresponder, this will also popup the keyboard: [self.textField

Move up keyboard when editing UITextField on iOS9

こ雲淡風輕ζ 提交于 2019-12-20 09:37:59
问题 For my keyboards to move up to uncover UITextField in my iOS app, I used to implement this answer: https://stackoverflow.com/a/6908258/3855618 on iOS7 and 8 and it has worked perfectly for now. However on iOS 9.1, it doesn't work anymore. To be more accurate, even if the background view does move up, the UITextField doesn't. Any idea of what has changed so much since iOS9 and iOS 9.1? 回答1: The answer you have linked is not recommended. You should not set the view controller view's frame