uitextfield

Objective C Textfield Default Value “•••••••” to "1•••••••”,“12•••••”,“123••••” when user click number

拈花ヽ惹草 提交于 2019-12-10 23:55:56
问题 I want to create textfield that has default value “•••••••” , when user click a number on UIKeyboardTypeNumberPad, it will be added textfield like that “1••••••”(for example clicked number 1) and “12•••••”(for example second clicked number 2).Each click to UIKeyboardTypeNumberPad will be added to textfield respectively. How can i do this? Thanks. 回答1: I have used some trick to do this.. First drag UILable and set text with ●●●●●●●. Now drag a UITextField and put it over UILable. Now change

UITextField — observe changes to selectedTextRange?

左心房为你撑大大i 提交于 2019-12-10 23:53:32
问题 Is there any way to observe changes to the selectedTextRange of a UITextField? I tried observing all UIControlEvents. But changing the selectedTextRange does not trigger a UIControlEvent. Another dead end -- UIKit classes are not KVO compliant. Then there is the UITextFieldTextDidChangeNotification. But that's for changes to the text. Any ideas? 回答1: Subclass UITextField as follows. @interface WJTextField : UITextField @end @protocol WJTextFieldDelegate <UITextFieldDelegate> - (void)

How do I access text in UITextField from another ViewController (Swift)?

笑着哭i 提交于 2019-12-10 23:31:45
问题 I have a UITextField on one ViewController and I want to be able to have a Label on the second ViewController = whatever the user enters. However, I get an error when trying to do this. I know Swift doesn't use import so I'm not sure what to do. // First View Controller @IBOutlet weak var textOne: UITextField! // Second View Controller @IBOutlet weak var theResult: UILabel! theResult.text = textOne.text Error: Unresolved Identifier 回答1: It looks like that you in reality want to just access

How to prevent specific characters from being typed in textfield?

这一生的挚爱 提交于 2019-12-10 23:06:44
问题 I would like to know how I could prevent certain characters from being allowed to be typed in a UITextfield. For example If I do not want the letters A,G,P,Q,X from being typed inside this textfield but the rest of the letters are allowed. I am very new to this and thank you for the help! 回答1: You need to use UITextViewDelegate for that. Catch user's input in one of the delegate methods, and handle it as you wish. Here is the Apple Reference for it: https://developer.apple.com/library/ios

How to require a minimum text length in UITextField before enabling keyboard return key

陌路散爱 提交于 2019-12-10 20:27:41
问题 In my app users register or login at a site that requires passwords at least 6 characters long. To work with that I'd like to impose that minimum in the password UITextField before the keyboard return button is enabled. Setting Auto-enable Return Key in the XIB causes the return key to be disabled until there is at least one character & (contrary to my expectations) turning that off causes the return key to be anabled even with no text. Can anyone tell me how I can keep the return key

Fade UITextField text

只愿长相守 提交于 2019-12-10 19:47:33
问题 I want to be able to make the text fade in a uitextfield when I change it. I've tried [UIView animateWithDuration:0.25 animations:{ textview.text = @""; }]; but that didn't work. It would be easier if I could access the textfields UILabel, but I don't se any! Oh, and btw, I only want the text to be faded NOT the whole field Any help is appreciated! - JomanJi 回答1: You need to set the alpha of "textview" to the value you want to fade it to: [UIView animateWithDuration:0.25 animations:{ textview

UITextField problems in iOS 5 by changing UITextFieldBorderStyle at runtime

只愿长相守 提交于 2019-12-10 19:27:48
问题 I'm suddenly having trouble with some UITextFields now that I'm testing on iOS 5 devices, even though I built the app in iOS 5 SDK and already let the bug slip through to release. I have a textfield that allows input, and when you press a "lock" button, it calls: textField.enabled = NO; textField.borderStyle = UITextBorderStyleNone; The Field "hides" but still acts like a label - important function for the app. Then you press the "lock" button again and it calls: textField.enabled = YES;

Search bar at the top of a UIPickerView in Swift

泄露秘密 提交于 2019-12-10 19:23:58
问题 So I have a textField, which when the user presses, it shows a UIPickerView, which is populated from an array. Is it possible for there to be search bar at the top of the pickerView, so the user can search for something in the pickerView? I've not seen this done before so have no idea if it's possible? Thanks in advance. 回答1: UIPickerView is really meant for a few options - if you need to present something that has a lot more options, I would suggest a table view with a search bar. Search Bar

How to change placeholder color in UITextField on tvOS, so that the change is kept and it does not revert back to its default placeholder state?

一个人想着一个人 提交于 2019-12-10 19:21:05
问题 How to change placeholder color in UITextField on tvOS, so that the change is kept and it does not revert back to its default placeholder state? In viewDidLoad() I have added the following: self.txfUsername?.attributedPlaceholder = NSAttributedString(string: "Email", attributes:[NSForegroundColorAttributeName: UIColor(red:1.0, green:1.0, blue:1.0, alpha:1.0), NSFontAttributeName:UIFont(name:"GothamBook", size:38.0)!]) So at first the placeholder color is white, however when it looses focus it

Cursor is blinking in UITextField but keyboard doesn't appear

戏子无情 提交于 2019-12-10 19:17:42
问题 I got a simple detail view with a textfield. In detail's viewController I wrote this code: - (void) viewDidAppear:(BOOL)animated{ [self.textField becomeFirstResponder]; NSLog(@"is textField 1st responder %d", [self.textField isFirstResponder]); } When I push the detail into a navigation controller, I see " is textField 1st responder 0 " in my log. The keyboard doesn't appear. But the textfield has blinking cursor. What happens in this moment? Why the keyboard doesn't appears? I did try to