uitextfield

Swift: Become First Responder on UITextField Not Working?

只谈情不闲聊 提交于 2019-12-10 01:59:05
问题 I've created a custom UIViewController with one UITextField on Storyboard. On viewDidLoad , I set the UITextFIeld to becomeFirstResponder , nothing happened (no keyboards popped up). I then tried calling resignFirstResponder() , but it returned false. Next I tried to find who the first responder is through looping all the subviews using the code over @ Get the current first responder without using a private API. It turns out none of the sub views are the first responder. My ViewController in

Text jumps when animating position of UITextField subclass

巧了我就是萌 提交于 2019-12-10 01:08:39
问题 When I animate the location of my UITextField subclass, the text in the field jumps out of step with the location of the UITextField holding it, which is very jarring and I can't figure out why it happens: My subclass adds a button to the right hand side of the text field that when tapped calls a method on the view controller, which changes the textfield border colour and moves the text field up the screen by changing the top space constraint of the text field, and a couple of other views

reactivecocoa true shouldChangeCharactersInRange textfield equivalent

好久不见. 提交于 2019-12-09 23:20:15
问题 i begin with reactiveCocoa and i have some trouble with UITextfield. i try to do a basic check on a textField to display only 4 digit. i try to follow this exemple: http://nshipster.com/reactivecocoa/ but in here, shouldChangeCharactersInRange is always true so the textfield is always updated. i tried 2 solution : [RACSignal combineLatest:@[self.pinDigitField.rac_textSignal] reduce:^(NSString *pinDigit) { NSCharacterSet *numbersOnly =[NSCharacterSet characterSetWithCharactersInString:@

Formatting UITextField's text as Phone Number as user types in

梦想与她 提交于 2019-12-09 20:29:45
问题 I have a custom UITextField, which I am trying to 'format the input to phone number' as user types. What I want to achieve: Adding a prefixed + sign on the UITextField as the first character, that cannot be deleted. Format both the String variable and UITextField's text in the format of phone number nicely (+49 291 12345678) , rather than plain numbers (4929112345678) as user types in. I researched and found out that there is no built-in method for that. I've also found easy-to-use library

UITextField Validation visual feedback

家住魔仙堡 提交于 2019-12-09 16:01:29
问题 i have a uiTextField that i am validating input on, when i have invalid input what are some appropriate ways to show that the input is invalid? is there any built in mechanism for showing invalid input states? 回答1: It's pretty easy to add an 'warning' image to the left-hand side of a UITextField to indicate that the field needs a value. Try this: UITextField* field = .... your text field ... if ( fails_validation ) { field.leftViewMode = UITextFieldViewModeAlways; UIImageView* imageView = [

Why is UITextField animating on resignFirstResponder?

点点圈 提交于 2019-12-09 14:50:12
问题 Since iOS 8, UITextFields in a form behave very strangely. If I click an another text field or press Tab on the keyboard, the entered text animates upwards then reappears quickly. It happens every time after the view did loaded, and every now and then afterwards. It looks like this: My code looks like this: #pragma mark - <UITextFieldDelegate> - (BOOL)textFieldShouldReturn:(UITextField *)textField { if (textField == self.passwordTextField) { [self loginButtonClicked:nil]; } else if (textField

how can I dismiss keyboard when I will just touch anywhere except UITextField?

断了今生、忘了曾经 提交于 2019-12-09 14:40:24
问题 Hello I have two UITextFields in my application, and want to dismiss the keyboard when I just touch anywhere except the UITextFields how can I do this? 回答1: use tochesBegin method for this purpose - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [yourFirstTextField resignFirstResponder]; [yourSecondTextField resignFirstResponder]; } You do not need any thing else.When you touch anywhere on view then both textField resign no need to to know which one having focus.and when you

How to find out what UITextField caused a UIKeyboardWillShowNotification?

 ̄綄美尐妖づ 提交于 2019-12-09 14:20:13
问题 I am trying to use a customized keyboard in my application, but I am hitting problems when trying to restrict it to one particular UITextField. I based my code on this Xcode project (originally found on this blog). That code adds a custom UIButton (representing a 'decimal point') into the UIKeyboardTypeNumberPad keyboard view. It does it by subscribing to UIKeyboardWillShowNotification and modifying the keyboard when it appears. That Xcode project works great, but when I add an extra

iOS TextField 使用大全

主宰稳场 提交于 2019-12-09 14:14:15
// 初始化 textfield 并设置位置及大小 UITextField *text = [[UITextField alloc]initWithFrame:CGRectMake(20, 20, 130, 30)]; // 设置边框样式,只有设置了才会显示边框样式 text.borderStyle = UITextBorderStyleRoundedRect; typedef enum { UITextBorderStyleNone, UITextBorderStyleLine, UITextBorderStyleBezel, UITextBorderStyleRoundedRect } UITextBorderStyle; // 设置输入框的背景颜色,此时设置为白色 如果使用了自定义的背景图片边框会被忽略掉 text.backgroundColor = [UIColor whiteColor]; // 设置背景 text.background = [UIImage imageNamed:@"dd.png"]; // 设置背景 text.disabledBackground = [UIImage imageNamed:@"cc.png"]; // 当输入框没有内容时,水印提示 提示内容为 password text.placeholder = @"password"; //

UITextField手动编写

☆樱花仙子☆ 提交于 2019-12-09 14:00:39
一、UITextField手动编写控件 UITextField *txtAccount = [[ UITextField alloc ] initWithFrame : CGRectMake ( 10 , 10 , 300 , 30 )]; // 设置委托 [txtAccount setDelegate : self ]; // 设置占位符 [txtAccount setPlaceholder : @" 账号 " ]; // 设置颜色 [txtAccount setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"]; // 设置字体 [txtAccount setValue:[UIFont boldSystemFontOfSize:16] forKeyPath:@"_placeholderLabel.font"]; // 设置文本对齐 [txtAccount setTextAlignment : NSTextAlignmentLeft ]; // 设置样式 [txtAccount setBorderStyle : UITextBorderStyleRoundedRect ]; // 加入 view 中 [ self . view addSubview : txtAccount];