uitextfield

Hide placeholder Programatically using swift 3x

孤人 提交于 2020-01-14 05:51:04
问题 How to hide the placeholder of TextField programmatically using Swift 3x ? 回答1: You can not hide the placeholder of UITextField , but you can set it to empty String. self.textField.placeholder = "" Now textField doesn't show any placeholder later on if you want to show the placeholder simply set it with String that you want. self.textField.placeholder = "Enter name" 来源: https://stackoverflow.com/questions/41421850/hide-placeholder-programatically-using-swift-3x

save the text in a text field as a variable

血红的双手。 提交于 2020-01-14 05:26:22
问题 I have been searching for an hour with no success so hope one of you will have pity. I am using Xcode 9 and Swift 4. textIt.text = name Works perfectly and I have used it in my app but name = textIt.text brings up the error code: Value of optional type 'String?' not unwrapped; did you mean to use '!' or '?'? All I want to do is to put some text from a variable into a field so the user can change it then I put the text back into the variable. What am I doing wrong? 回答1: In swift if a variable

How to determine the cursor position of a UITextField?

吃可爱长大的小学妹 提交于 2020-01-14 04:32:10
问题 I have a text field that is always of the format "XX0000000XX", X being a letter, 0 being a number. I switch keyboards as the user is typing depending on whether they need to enter a number or letter. This works fine, until the user positions the cursor in the middle of the text field to make an edit. How do I determine the cursor position within a UITextField? I know a UITextView has a selectedRange that can be used, but I've read that you can't force a UITextView to be single line entry? i

KVO crash on UITextField initWithFrame

≯℡__Kan透↙ 提交于 2020-01-14 03:25:07
问题 A customer of my app sent me this strange crash report and I cannot figure out how this could ever crash. I cannot reproduce the problem myself, so am reliant on the crash report. It crashes on the following very simple line of code: UITextField *value = [[UITextField alloc] initWithFrame:frame]; The crash seems to be related to key-value-observing (KVO), but I am not doing anything with that here; it's a simply constructor! The only possibility I could see, is that another thread is writing

Get text from UITextField on a TableViewCell

半城伤御伤魂 提交于 2020-01-14 03:00:10
问题 I have a UITableViewController with prototype cells containing UITextFields. To configure these custome cells, I've created a UITableViewCell subclass. I've conected the textField to the cell subclass via an outlet (nonatomic, weak) . On this subclass I've created a protocol for which the UITableViewController is its delegate so that everytime something changes in these textFields, the TableViewController knows about it. Basically I wanted this to save the values on the NSUserDefaults Besides

Why Text is cutting from bottom in UITextField?

冷暖自知 提交于 2020-01-12 18:28:28
问题 I am using a custom font in my text fields and labels in my whole application. My font name is "digital-7.ttf". now the problem is that text in my labels is good but in the UITextFields it is cutting text from bottom. when textfield is editing then text is good but when editing is done then it cuts the text again. like this in this way i am setting its font style [txtFld setFont:[UIFont fontWithName:@"digital-7" size:25.0]]; and font has been added in info.plist Please help me 回答1: i just had

Why Text is cutting from bottom in UITextField?

萝らか妹 提交于 2020-01-12 18:28:17
问题 I am using a custom font in my text fields and labels in my whole application. My font name is "digital-7.ttf". now the problem is that text in my labels is good but in the UITextFields it is cutting text from bottom. when textfield is editing then text is good but when editing is done then it cuts the text again. like this in this way i am setting its font style [txtFld setFont:[UIFont fontWithName:@"digital-7" size:25.0]]; and font has been added in info.plist Please help me 回答1: i just had

Why Text is cutting from bottom in UITextField?

廉价感情. 提交于 2020-01-12 18:27:07
问题 I am using a custom font in my text fields and labels in my whole application. My font name is "digital-7.ttf". now the problem is that text in my labels is good but in the UITextFields it is cutting text from bottom. when textfield is editing then text is good but when editing is done then it cuts the text again. like this in this way i am setting its font style [txtFld setFont:[UIFont fontWithName:@"digital-7" size:25.0]]; and font has been added in info.plist Please help me 回答1: i just had

Adding textfield to SKScene

不想你离开。 提交于 2020-01-12 08:49:42
问题 I am creating a game using Sprite Kit, and I want to add a textfield for players to enter their name. How can I create a textfield using Sprite Kit? I'm going to create a player object (which I already have set up) and use the name they enter and a default score of 0. Is it bad practice, or even possible, to mix UITextfields and Sprite Kit nodes? 回答1: Something like this UILabel *nameField = [[UILabel alloc] initWithFrame:CGRectMake(200, 200, 300, 100)]; [self.view addSubview:nameField]; But

Disable button until text fields have been entered?

戏子无情 提交于 2020-01-12 07:46:44
问题 I have several uitextfields within a view and I would like to disable the uibutton until all the fields have something entered into them. What's the best way of doing this? Ideally, I'd like to do some basic validation (make sure all entries are numbers) too. EDIT Couldn't get the solutions below to quite work. Below is the version that I got working (cobbled together from Brad, Mike, and various other sources) Use the UITextFieldDelegate Create textfields in IB, and attach to the relevant