uitextfield

How to test UITextField in Xcode UI Testing when the text field is empty?

有些话、适合烂在心里 提交于 2019-12-07 13:42:01
问题 I am making a UITest in Xcode. When I record my test it works fine but when I run the test, it gives an error. These are the lines of code where the error occurs: XCUIElement *clearTextTextField = [app.textFields containingType:XCUIElementTypeButton identifier:@"Clear text"].element; [clearTextTextField typeText:@"sheffield"]; The error says UI Testing Failure - No matches found for textfield I imagine this is because my Text Field does not have any initial string and the tester cannot find a

UITextField with rounded corners only on top

泄露秘密 提交于 2019-12-07 13:40:26
问题 I want to implement an UITextField which has rounded corners only at top left and top right corner. I know about the setter method setCornerRadius: which is a default option of UITextField, but this option only allows me to make all four corners of the txtfield round, but i only want the corners on the top to be round. I'm now messing around since hours, I have read through Appple's docs a dozen of times, but I'm still unable to find out why my code wont work: - (id) init { // init elements

iOS UITextField changes position when text is changed

拜拜、爱过 提交于 2019-12-07 12:32:28
问题 I use this to center a text field over something relevant: [textField setCenter:[someObject center]]; [textField becomeFirstResponder]; This looks great, nice and centered over the object, ready to accept text. I'd like the text formated a certain way, so in the editing changed handler, I revise the text and set to the new text: [textField setText:newText]; When I do this, the text field will jump to its the old position, from before it was centered. I'd like the text field to stay centered

Dynamic searching in tableview in iOS

假装没事ソ 提交于 2019-12-07 11:58:44
问题 I've a tableview and text field where I've implemented search method. Right now, when I write some value in textfield and click search button, then it search in the tableview . But, I want it to be dynamic means the moment I start typing in textfield it should start searching without clicking any button . How can I do this? 回答1: Just Connect this method on Editing Changed Event of your TextField . So, this method is called when you are changing its value. - (IBAction)txtValueChanged:

Hide keyboard by touching background of UITableView

随声附和 提交于 2019-12-07 11:35:32
I was searching some optimized method to hide keyboard on background tap when UITextFields are in a UITableViewCell . I have made some code Hope this would help you. Sj. Doing hittest doest seem to be the right way You can implement the touch events on the View on which the tableView resides, like below. Also assign the textField Object to a member variable in textFieldDidBeginEditing , so you will be able to resign the particular text field for which the keyborad is shown. -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [textFieldObject resignFirstResponder]; } Umair I made

IOS键盘的相关设置(UITextfield)

旧街凉风 提交于 2019-12-07 11:32:47
一、键盘风格 UIKit框架支持8种风格键盘。 typedef enum { UIKeyboardTypeDefault, // 默认键盘:支持所有字符 UIKeyboardTypeASCIICapable, // 支持ASCII的默认键盘 UIKeyboardTypeNumbersAndPunctuation, // 标准电话键盘,支持+*#等符号 UIKeyboardTypeURL, // URL键盘,有.com按钮;只支持URL字符 UIKeyboardTypeNumberPad, //数字键盘 UIKeyboardTypePhonePad, // 电话键盘 UIKeyboardTypeNamePhonePad, // 电话键盘,也支持输入人名字 UIKeyboardTypeEmailAddress, // 用于输入电子邮件地址的键盘 } UIKeyboardType; 用法用例: textView.keyboardtype= UIKeyboardTypeNumberPad; 二、键盘外观 typedef enum { UIKeyboardAppearanceDefault, // 默认外观:浅灰色 UIKeyboardAppearanceAlert, //深灰/石墨色 } UIKeyboardAppearance; 用法用例: textView

When set UITextField as FirstResponder programmatically, cause some weird actions on text editing

ⅰ亾dé卋堺 提交于 2019-12-07 10:24:56
问题 I have a UITextField with custom keyboard, basically like a calculator. I would like my keyboard show up by default, so i used [self.topInputTextField becomeFirstResponder]; in viewDidLoad , I think that's very common usage. However, it causes some very weird actions on my textfield. When i set my textfield as the first responder in viewDidLoad, and every time after i done editing, the text will jump, and when i click another text field and and click the first text field again, the texts in

Adding text to UITextField you can't delete

為{幸葍}努か 提交于 2019-12-07 10:12:57
问题 What I would like to do is to add some text at the beginning of UITextField that cannot be deleted. I add this text when the user taps on UITextField like this: - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{ if (textField.text.length == 0) { textField.text = @"myText"; } return YES; } How do I prevent the user from deleting this text in a normal way? ( without adding a separate UILabel on top of the TextField, for example). Thanks in advance! 回答1: You can implement this code in

How may i customise all UITextField appearances for borderWidth?

流过昼夜 提交于 2019-12-07 08:41:03
问题 i am trying to customise all UITextField appearances for borderWith. Trying something like this. Only first 2 lines are making a difference. Rest of the lines not working ? [[UITextField appearance] setBackgroundColor:[UIColor greenColor]]; [[UITextField appearance] setTextColor:[UIColor blackColor]]; [UITextField appearance].layer.cornerRadius = 6.0f; [UITextField appearance].layer.borderColor = [UIColor redColor].CGColor; [UITextField appearance].layer.borderWidth = 3.f; 回答1: Unfortunately

iOS Accessibility hide the “textField, double tap to edit” announcement

冷暖自知 提交于 2019-12-07 07:31:09
问题 I have a textField with a pickerView as the inputView. Now when I have the voiceover on and select the textField, the voiceover will read this: "Quantity: 3 (content of the textField)", then "textField", then "Double tap to edit". Is there anyway to make the voiceover just reads the content and skip the following "textField. Double tap to edit"? I have tried to give the textField another UIAccessibilityTraits/Hints and they are not working. Thanks! 回答1: Assuming your text field is a subclass