uitextfield

Limit UITextField to one decimal point Swift

房东的猫 提交于 2019-12-06 05:43:11
How can I limit a UITextField to one decimal point with Swift? The text field is for entering a price, so I cannot allow more than one decimal point. If I was using Objective-C, I would have used this code: -(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSString *newString = [textField.text stringByReplacingCharactersInRange:range withString:string]; NSArray *sep = [newString componentsSeparatedByString:@"."]; if([sep count] >= 2) { NSString *sepStr=[NSString stringWithFormat:@"%@",[sep objectAtIndex:1]]; return !(

Change Keyboard Language In iOS App When Click In UITextField

China☆狼群 提交于 2019-12-06 05:36:52
i tried many ways to change keyboard in ipad programmatically but it doesn't change at all . i cant find any property in uitext for doing this. any idea? Unfortunately, you cannot control the language of the keyboard. The user chooses which keyboards they would like available via the settings application and can toggle between them using the globe icon on the keyboard. When the keyboard is opened it will open to the most recently used keyboard. Here is what you need my friend, [textView setKeyboardType:UIKeyboardTypeNumberPad]; [txtField setKeyboardType:UIKeyboardTypeNumberPad]; 来源: https:/

Swift - How to multiply value from UITextField

不想你离开。 提交于 2019-12-06 05:13:35
@IBOutlet weak var labelLabel: UILabel @IBOutlet weak var textFieldField: UITextField @IBAction func buttonButton(sender: AnyObject) { var conversionRate = 7 self.labelLabel.text = self.textFieldField.text // Here I'm trying to multiply textFieldField by 7 (conversionRate) textFieldField.resignFirstResponder() } Hello, I want to multiply a value from UITextField by 7. Can someone help me? I've tried everything. .toInt(), intValue() and nothing It should work with .toInt() : if let number = self.textFieldField.text?.toInt() { self.labelLabel.text = "\(number * conversionRate)" } You can try

Text as Hyperlink in Objective-C

吃可爱长大的小学妹 提交于 2019-12-06 05:05:55
I have a text label with the text set as Contact Us.. When user taps on this label it should launch safari to open the web page.My doubt is how to make Contact Us as hyperlink.Now I can't modify my code to include a UIWebView..Please help me guys..I am in final stages of my project..If possible please help me with sample code..thanks for all your time The easiest way is to make the UILabel into a UIButton, style it (use Custom type to get rid of button look). Then connect to an Action that opens safari. The action should do this: NSURL *url = [[[ NSURL alloc ] initWithString: @"http://www

iOS - Implementing a Class for UITextField

做~自己de王妃 提交于 2019-12-06 04:43:56
I have a UIView , with lots of UITexfields , UITextField *field1 = [[UITextField alloc] initWithFrame:CGRectMake(135, 292, 50, 20)]; field1.backgroundColor = [UIColor clearColor]; field1.borderStyle = UITextBorderStyleNone; field1.returnKeyType = UIReturnKeyNext; field1.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom; field1.font = [UIFont fontWithName:inputFont size:fontSize]; field1.placeholder = @"size"; [self addSubview:field1]; Can I create a UITextField Class and create an instance of this class with these parameters preset? -so as to reduce the code: (If I have lots

Cannot remove border of UITextField dynamically

岁酱吖の 提交于 2019-12-06 04:28:58
问题 I want to remove the border of UITextField dynamically. I tried [stringTextField setBorderStyle:UITextBorderStyleNone]; but nothing happened. Any idea? 回答1: Is the TextField already displayed in the view when this happens? If so, you (probably) need to execute the following: [stringTextField setBorderStyle:UITextBorderStyleNone]; [stringTextField setNeedsDisplay]; in order for the view to redraw the TextField , sans border. Note that there's no guarantee the system will immediately redraw the

How do I check UITextField values for specific types of characters e.g. Letters or Number?

送分小仙女□ 提交于 2019-12-06 04:28:21
What I want to do is set some boolean in the if statement below to true if anything other than letters, numbers, dashes and spaces is contained in the textField. Then for an email field check for a valid email. This is how I'm checking for length: if countElements(textField.text!) < 2 || countElements(textField.text) > 15 { errorLabel.text = "Name must have between 2 and 15 characters." self.signUpView.signUpButton.enabled = false } else { errorLabel.text = "" self.signUpView.signUpButton.enabled = true } This if statement is inside the UITextFieldDelegate method textFielddidEndEditing. I have

UITextField SecureEntryText color changes

天涯浪子 提交于 2019-12-06 03:53:28
I have a subclass of UITextField where I set the text color to be white. I am using this subclass for an email field and a password field. - (void)drawRect:(CGRect)rect { [super drawRect:rect]; self.clearButtonMode = UITextFieldViewModeWhileEditing; self.layer.backgroundColor = [UIColor clearColor].CGColor; self.textColor = [UIColor whiteColor]; [self setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"]; ...... ...... The password field has secureTextEntry set to YES , and when I first type in it the color is white as expected. Then, if I click the clear button, focus on

iPhone 5 Keyboard sizing

寵の児 提交于 2019-12-06 03:35:52
问题 I've been testing my app in the 4-inch and 3.5-inch iPhone simulators, and when bringing up a keyboard with a UITextField in the 4-inch simulator in landscape mode, it's squished up to the side. It looks like a normal 3.5-inch keyboard: Am I missing something telling it to stretch properly? Please note - I don't have access to an actual iPhone 5 device to test on. Any help would be appreciated. 回答1: Maybe your simulator is set to the 4-inch model but is running iOS5--this setup is possible in

XCode 6.1 iOS 8 keyboard decimal pad is not properly

心不动则不痛 提交于 2019-12-06 02:01:08
问题 My iPhone app was normal in xCode 5 and iOS 7. When I updated to xCode 6.1, it was still normal. But after I update iOS 7 to iOS 8 (now xCode 6.1 and iOS 8), the keyboard type DecimalPad of uitextfield is not working property The decimal button is a half the size it should, and when touch on the "red rectangle", the number "7" is selected. It also warning "Can't find keyplane that supports type 8 for keyboard iPhone-Portrait-DecimalPad; using 1425143906_Portrait_iPhone-Simple-Pad_Default". I