uitextfield

allow only to enter english characters in iPhone UITextField

六月ゝ 毕业季﹏ 提交于 2019-12-12 17:06:32
问题 I want to allow user to enter only english alphabets and characters. How can i prevent user from entering other characters than english. 回答1: Check out UIKeyboardType - there is an option to support only ASCII (UIKeyboardTypeASCIICapable). Also, there are options in the UITextFieldDelegate protocol that could allow you to selectively filter input. Take a look at: - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string; 来源:

Position “Clear Button” in UITextfield

余生颓废 提交于 2019-12-12 15:42:44
问题 Is there a way to position the clear button? I would like to move it down by just a little bit so it's on the same level with the text input. Any ideas? My Textfields are already Subclasses of another Class that handles the effects. Including the "clearButtonRect" function doesn't work. @IBDesignable open class HoshiTextField: TextFieldEffects { //effect functions.. override open func clearButtonRect(forBounds bounds: CGRect) -> CGRect { return CGRect(x: 0, y: 0.2, width: 0.1, height: 0.3) }

shouldChangeCharactersInRange call twice

不打扰是莪最后的温柔 提交于 2019-12-12 13:55:23
问题 Sometimes, shouldChangeCharactersInRange is called twice when I hit only one character. As an exemple, i enter 'avion par c', the procedure is called and add me a second 'c' result is 'avion par cc' - How can I avoid that ? This happened only since I migrate the application to iOS 7, xCode 5. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { wordSearching = YES; if ([string isEqualToString:@"\n"]) { [self

Enabling button if I write in TextField

大兔子大兔子 提交于 2019-12-12 13:18:47
问题 I am having some problems with enabling a button when you write something in a TextField. I got it to disable if a there's nothing in the TextField but I can't make it to enable again when you write something in it. I have something like this: - (void)viewDidLoad { [super viewDidLoad]; NSUInteger textLength = [_Name.text length]; [_doneButton setEnabled:(textLength > 0)]; } 回答1: Try this - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:

How to display keyboard in iOS8

≯℡__Kan透↙ 提交于 2019-12-12 13:05:24
问题 Im trying to convert my iOS7 project to iOS8 When I built the app in iPhone 5s simulator for iOS8.0, I found the keyboard would no longer appear automatically when clicking a UITextField or UITextView ... Is there any one can tell me how to solve this? thanks~ 回答1: To fix this, on simulator, open the Menu: Hardware - Keyboard - Toggle software menu (make sure it's checked) 回答2: I had a similar problem that was the reverse of the above. When I built the app in simulator for iOS7.0 the keyboard

Move view up when keyboard is presented

北战南征 提交于 2019-12-12 12:30:30
问题 The Question: I have a ViewController that has a subclass with a UIScrollView in it. In the scrollView there are 3 UITextField s. 2 of them with a numberPad keyboard and 1 with a UIPickerView keyboard. The problem is that when the keyboards are presented, it hides the UITextField s. So what I'm trying to do is to move the UIViewController 's view up when the keyboards are being shown. What I've already tried: I've searched this question on SO and I've found some answers, based on them I've

UItextField Delegate not working

梦想的初衷 提交于 2019-12-12 11:35:15
问题 In my iPad app I have two textfields. One displays the normal, default textfield and the other should display a picker as its input view. Problem is, once I use the txt1 which displays default keyboard and then when I touch the 2nd textField the txt1 keyboard is staying visible. I have also written [txt1 resignFirstResponder]; [txt2 resignFirstResponder]; while displaying the picker. I have checked the txt1 IBOutlet connection and the delegate assignment, those seem to be correct. What am I

how to convert Arabic numbers to English numbers in swift?

帅比萌擦擦* 提交于 2019-12-12 11:23:50
问题 in my app, I have 5 uitextfields. My intended users are Arabic speakers so when they use my app, they will either insert number in English or in Arabic. The app works just fine with English numbers. However, when I run it and insert numbers in Arabic, the app deals with the textfields as if they all were empty and gives the answer as 0 How can I make sure that the textfields are not nill AND a double, whithout ignoring Arabic numbers? This is the code inside the "calButton" function: /*let

Get UITextField Y coordinate on UIView level?

烈酒焚心 提交于 2019-12-12 10:54:59
问题 Currently I have a UITextField in a custom cell and I want to get the Y coordinate of that UITextField on the level of the View Controller's view (UIView). Currently I am trying to do something like this: if (thetextField.superview.superview.superview.frame.origin.y >= keyboardY) { } But it seems that the Y coordinate is always 0 when it is in fact not. Is there any way to achieve this? I am doing this because I want to detect whether the UIKeyboard is blocking the UITextField on the UIView

iPhone keyboard doesn't appear when entering a UITextField

允我心安 提交于 2019-12-12 10:32:12
问题 This has to be some kind of newbie blunder that I just can’t see, and I’d be grateful for hints as to what to check or where to look. I've followed an iPhone tutorial that has a UITextField, making sure I connected the IBOutlet for the text field, and it seems to compile properly (no errors or warnings). But when I run it under the simulator, and click in the field, I don’t get the keyboard, so I can’t enter anything into the field. I’ve tried searching the site for similar questions, and all