uitextfield

UITextField minimum fontsize

南楼画角 提交于 2019-12-17 19:59:19
问题 I'm using the property minimumFontSize textField.font = [UIFont boldSystemFontOfSize:17]; textField.textColor = [UIColor darkGrayColor]; textField.minimumFontSize = 10; textField.adjustsFontSizeToFitWidth = YES; But the text never goes to minimum font size of 10, it gets truncated, but if I change the current fontSize to 10, the whole text appears correctly. Am I using this property wrong? 回答1: As late as it is ... you were setting up your UITextField correctly, and adjustsFontSizeToFitWidth

UITextField attributedPlaceholder has no effect

柔情痞子 提交于 2019-12-17 19:38:09
问题 I'm trying to make the placeholders in my textfields italic, and since my app is targeting iOS 6.0 or newer, decided to use attributedPlaceholder property instead of rolling something more custom. The code goes as follows: NSString *plString = @"optional"; NSAttributedString *placeholder = [[NSAttributedString alloc] initWithString:plString attributes:@{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-LightItalic" size:15]}]; for (UITextField *t in myTextfields){ t.placeholder =

iOS multiple text fields on a UIAlertview In IOS 7

爷,独闯天下 提交于 2019-12-17 19:36:37
问题 So the new iOS 7 has come out and I'm trying to add multiple textFields and labels to the UIAlertviews. I need three. I've been trying to add them as subviews and that doesn't work anymore. I have also tried to add multiple lines with the UIAlertViewStylePlainTextInput but it only seems to return one text field. I need to add in labels to show them what to enter as well. Is there a way to accomplish this task with the new iOS 7? 回答1: The only solution i found using UIAlertView with more than

Multi-line TextField (similar to SMS) and / or 'Done' button in UITextView

无人久伴 提交于 2019-12-17 19:27:12
问题 I've been researching this for a few days now, and would appreciate a little help. Is there any way to generate a multi-line UITextField like Apple use in the SMS application? The useful thing about this control is that it has the 'sunk' appearance that makes it clear that it is a text entry box, but at the same time, it expands on each new-line character. Failing that, if I'm forced to use a UITextView, can anyone advise how best to dismiss the keyboard ? Both the 'Done' and the 'Go' buttons

Add a Done button within a pop-up datePickerView in Swift?

对着背影说爱祢 提交于 2019-12-17 18:24:23
问题 I want to add a Done button within a popped up datePickerView in Swift. Here is the code: @IBOutlet var datePicker: UITextField! @IBAction func dateTextInputPressed(sender: UITextField) { var datePickerView = UIDatePicker() datePickerView.datePickerMode = UIDatePickerMode.Date sender.inputView = datePickerView datePickerView.addTarget(self, action: Selector("handleDatePicker:"), forControlEvents: UIControlEvents.ValueChanged) } func handleDatePicker(sender: UIDatePicker) { var dateFormatter =

How to restrict certain characters in UITextField in Swift?

最后都变了- 提交于 2019-12-17 16:50:21
问题 I am creating a trivia application that asks for a username on start up. I'd like to make it impossible to use characters such as #$@!^& etc (also including "space"). I took a look at this post here but it is written entirely in Objective-C. Thanks in advance. 回答1: Since you're explicitly asking for Swift, I've translated the top asnwer in the linked question. let notAllowedCharacters = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_."; func textField( textField: UITextField

How to use one UIPickerView for multiple textfields in one view?

做~自己de王妃 提交于 2019-12-17 16:45:30
问题 I have 8 textfields in one view. I want to populate each using a pickerview. Can I have 1 pickerview which will display different list of items from different arrays for different textfields? Can someone explain how do I do it programmatically with a sample code? Also how can I hide the pickerview when the view loads and it should be displayed only when I click on a textfield with its corresponding data list? It should disappear when I select the data and reappear when I click on a different

Disable Magnifying Glass in UITextField

穿精又带淫゛_ 提交于 2019-12-17 16:31:29
问题 Is there a way to prevent the user from moving the cursor in a UITextField? I'd like it to stay at the end of the string. 回答1: There's no way to prevent them from moving the cursor. You can, however, prevent them from editing the text except at the end by implementing the – textField:shouldChangeCharactersInRange:replacementString: method in your text field's delegate. Edit: you can also set userInteractionEnabled to NO so that the user can't tap the field. Call becomeFirstResponder manually

Allowing single digit in UITextField in iOS

自古美人都是妖i 提交于 2019-12-17 15:38:32
问题 I have a Verification ViewController , I get 4 digit verification code by SMS and I need to enter those code to login, I have created the ViewController like this As you can see four UITextField s, I need to allow only single digit for each UITextField , What I tried: I was trying to use shouldChangeCharactersInRange:method: , but its not getting called, I don't know what's wrong, I think because UITextField s are in UITableView so it is not working. 回答1: You can change the text field like

UITextField - capture return button event

試著忘記壹切 提交于 2019-12-17 15:27:25
问题 How can I detect when a user pressed "return" keyboard button while editing UITextField? I need to do this in order to dismiss keyboard when user pressed the "return" button. Thanks. 回答1: - (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; return NO; } Don't forget to set the delegate in storyboard... 回答2: Delegation is not required, here's a one-liner: - (void)viewDidLoad { [textField addTarget:textField action:@selector(resignFirstResponder)