uitextfield

iPhone SDK - UITextField with + Button for Contacts

爱⌒轻易说出口 提交于 2019-12-20 09:24:44
问题 In some applications like Mail, when you have a UITextField, there is a little + button to the right. When you tap it, a modal view controller comes up which you can select a phone number, address, etc from, and it will appear in the text field. I was wondering how to implement this in my own app. Thanks, Isaac 回答1: If you want the plus button inside the text field, take a look at the rightView property of the UITextField class, which lets you put any UIView in the right-most portion of the

Custom UITextField clear button

不打扰是莪最后的温柔 提交于 2019-12-20 08:47:09
问题 Is it possible to customize the image of the clear button in a UITextField ? I have a dark textfield background and the "x" is not visible enough. 回答1: You can set your own custom clear button to the text field's rightView property. Make sure set the rightViewMode property to UITextFieldViewModeWhileEditing or UITextFieldViewModeAlways , whatever makes sense for your case. If the button's position isn't right for your need, you can subclass UITextField and override the rightViewRectForBounds:

UITextField to Int to UILabel

北战南征 提交于 2019-12-20 07:39:27
问题 I'm used to C# and java, swift is definitely a different beast! I've been struggling for hours trying to get this to work. It is something so simple as well! I just want to get the text from a UITextField and turn it into an Int and then send the Int to a UILabel!! So many answers on the internet haven't worked at all! This is the error i'm getting now. ( using Xcode 8.2.1 and Swift 3.0.2 ) import UIKit class ViewController: UIViewController { @IBOutlet weak var firstTextField: UITextField!

How would I save and load a UITextField?

China☆狼群 提交于 2019-12-20 06:55:32
问题 I have searched everywhere and tried lots of code but nothing seems to be working for me. All I need to do is to load (on viewDidLoad) a text field and save it when a button is pressed. What is the easiest method of doing this? I am working with a single window application, I don't have a view controller (this may make a difference?) Thanks, James 回答1: Using an SQLite database: -(IBAction) checkNotes{ sqlite3_stmt *statement; const char *dbpath = [databasePath UTF8String]; if (sqlite3_open

How would I save and load a UITextField?

妖精的绣舞 提交于 2019-12-20 06:55:15
问题 I have searched everywhere and tried lots of code but nothing seems to be working for me. All I need to do is to load (on viewDidLoad) a text field and save it when a button is pressed. What is the easiest method of doing this? I am working with a single window application, I don't have a view controller (this may make a difference?) Thanks, James 回答1: Using an SQLite database: -(IBAction) checkNotes{ sqlite3_stmt *statement; const char *dbpath = [databasePath UTF8String]; if (sqlite3_open

Get uitextfield data from custom uitableview cell - Swift

只谈情不闲聊 提交于 2019-12-20 06:20:30
问题 I have a problem with custom tableview cell with a textfield. So, I have a separate class for a cell with a textfield, but I can't retrieve data in my tableview class. There is a delegate for textfield in tableview class and textFieldShouldReturn function but nothing happens when I press "Done" button. Where can be a problem? Thanks a lot! Here's a code for Table View: class MainTVC: UITableViewController, UITextFieldDelegate{ var tableParts: [Dictionary<String, Any>] = [] override func

custom UITextField with image as a background blinking cursor issue

邮差的信 提交于 2019-12-20 05:47:07
问题 I have a custom UITextField with a UIImage as a background. Now when I type in a text into this UITextField and the cursor is blinking I get this: I don't want to have a white image on the cursor blinking as it destroys the aesthetics. I tried playing around with this and tried setting the background view to have the same color as the image, however the issue is that the UITextField shape is always a rectangle. How do I solve this? 回答1: Have you tried setting textField.backgroundColor =

want to know ever time while pressing on keyboard back button during textfield editing ios

一笑奈何 提交于 2019-12-20 04:23:29
问题 In OTP, there are four textfields were used. Moving the cursor to the previous textfield while pressing on keyboard back button? 回答1: To detect the backspace event in a UITextField, first you need to set up a delegate for the UITextField and set it to self. class ViewController: UIViewController,UITextFieldDelegate self.textField.delegate = self Then you use the delegate method below to detect if a backspace was pressed func textField(_ textField: UITextField, shouldChangeCharactersIn range:

iPhone: how can I activate a text field programmatically (and not wait for the user to touch it)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 03:53:00
问题 I have a UIViewController that is a UITextFieldDelegate, and I would like the keyboard for its text field to appear as soon as the user navigates to this view, without having to actually touch the text field. It would also be nice to be able to "dismiss" the entire view when the keyboard is dismissed. I am loading the view from a xib file. I don't have an ivar in the code for the UITextField as yet. I would guess I need one. At this point I am just relying on the delegate to pop up the

How can we keep a text field's font size relative to the screen size?

天大地大妈咪最大 提交于 2019-12-20 03:23:56
问题 I have a text field and I have given it a regular font with 13 px in size. But I want the font size to increment with respect to screen size. Thanks. 回答1: You can calculate the font size based on the screen's dimensions. let baseWidth: CGFloat = 320 // the width of the screen where you want to use 13pt let fontSize = 13 * (UIScreen.main.size.width / baseWidth) let font = UIFont(name: "HelveticaNeue", size: fontSize) 回答2: You can simply do this by checking, Automatically Adjusts Font in the