Tag: uitextfield

如何在Xcode UItesting中testingUITextField何时文本字段为空?

我在Xcode中做了一个UITest 。 当我logging我的testing它工作正常,但是当我运行testing,它会给出一个错误。 这些是发生错误的代码行: XCUIElement *clearTextTextField = [app.textFields containingType:XCUIElementTypeButton identifier:@"Clear text"].element; [clearTextTextField typeText:@"sheffield"]; 错误说 UItesting失败 – 找不到与textfield匹配的内容 我想这是因为我的文本字段没有任何初始string,并且testing人员找不到具有初始string"Clear Text"的文本框。 我在YouTube上观看了以下教程。 示威者的代码很好,因为他的文本字段有一个初始string。 (至less这是我认为的问题是) 有没有办法使空白文本字段的testing工作?

如何隐藏IQKeyboardManager中的工具栏iOS Swift 3

我正在使用IQKeyboardManger库在使用键盘开始键入时滚动文本字段,但我不想显示其库中的默认工具栏。 以下是我用过的代码。 override func viewDidLoad() { super.viewDidLoad() self.chatTextField.inputAccessoryView = [[UIView alloc] init]; //This will remove toolbar which have done button. self.chatTextField.keyboardDistanceFromTextField = 8; //This will modify default distance between textField and keyboard. For exact value, please manually check how far your textField from the bottom of the page. Mine was 8pt. }

禁用UITextfield的键盘

我想知道如何禁用UITextfield的inputview。 设置textField.inputView = nil; 或ShouldBeginEditing中的[textField setInputView:nil]不会执行任何操作,并且使用userInteraction属性将删除与字段交互的function。 理想情况下,我想删除光标和键盘,同时仍然可以交互和使用ShouldBeginEditing和ShouldEndEditing的文本字段方法之间切换。 有什么办法可以做到这一点?

是否有可能animationUIEdgeInsets?

我一直试图在UIEdgeInsets改变animation。 我已经尝试使用UIView.animateWithDuration和insets只是跳转到最后的值。 有没有人知道这是一个不能animation的属性? 或者更好的是,是否有人知道一个animation内嵌的方法? 举个例子: // Starting inset values self.searchField.placeHolderInset = UIEdgeInsets(top: 0, left: 110, bottom: 0, right: 10) // Animation block UIView.animateWithDuration(0.1, animations: { self.searchField.placeHolderInset = UIEdgeInsets(top: 0, left: 18, bottom: 0, right: 10) }) 而不是在0.1秒内向左移动92像素,文本跳转到最终值。 searchField是一个UITextField而.placeHolderInset是用来确定UITextField占位符文本的插入符的UIEdgeInset。 编辑:另一种达到预期效果的方法是将UITextField的.textAlignment从.Center .textAlignment为.Center ,但不会animation。

如何将文本字段提示设置为斜体(使用常规的实际文本)?

有没有简单的方法来设置文本字段的提示斜体,而保持实际的文字非斜体? 下面的图片显示了我正在尝试完成的内容,但实际上并没有工作,因为键入第一个文本字段的文本仍然以斜体显示。 如果没有简单的方法做到这一点,我想我将不得不在每个文本字段上实现方法来检查文本的长度,如果零应用斜体字体。 这会工作,对吗? 有没有更好的办法?

带圆angular的UITextField只在顶部

我想实现一个只有左上angular和右上angular有圆angular的UITextField。 我知道setter方法setCornerRadius:这是UITextField的默认选项,但是这个选项只允许我把txtfield的所有四个angular都舍去,但是我只希望顶部的angular是圆的。 我现在在几个小时左右就搞乱了,我已经通过Appple的文档读了十几遍,但是我仍然无法知道为什么我的代码不能工作: – (id) init { // init elements UITextField *txt_password = [[UITextField alloc] init]; UIView *txt_password_paddingVc = [[UIView alloc] initWithFrame:CGRectMake(0,0,10,35)]; // configure txtfield [txt_password setSecureTextEntry:YES]; [txt_password setDelegate:self]; [txt_password setTag:100]; [txt_password setPlaceholder:t(@"App Password")]; [txt_password setLeftView:txt_password_paddingVc]; [txt_password setRightView:txt_password_paddingVc]; [txt_password setBackgroundColor:[UIColor whiteColor]]; [txt_password setLeftViewMode:UITextFieldViewModeAlways]; [txt_password setRightViewMode:UITextFieldViewModeAlways]; [txt_password setTranslatesAutoresizingMaskIntoConstraints:NO]; [txt_password setAutocapitalizationType:UITextAutocapitalizationTypeNone]; [txt_password setAutocorrectionType:UITextAutocorrectionTypeNo]; [txt_password.layer setBorderColor:[UIColor colorWithRed:228/255.0 green:228/255.0 […]

添加文本到UITextField你不能删除

我想要做的是在UITextField的开头添加一些无法删除的文本。 当用户像这样在UITextField点击时,我添加这个文本: – (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{ if (textField.text.length == 0) { textField.text = @"myText"; } return YES; } 如何防止用户以正常方式删除此文本? (例如,在TextField的顶部不添加单独的UILabel )。 提前致谢!

在iOS中的tableview中dynamicsearch

我有一个tableview和文本字段,我已经实现了search方法。 现在,当我在textfield写入一些值,然后单击searchbutton,然后在tableviewsearch。 但是,我希望它是dynamic的意思是我开始在textfieldinput的时候,它应该开始search而不点击任何button 。 我怎样才能做到这一点?

UITextField SecureEntryText颜色更改

我有一个UITextField的子类,我把文本颜色设置为白色。 我正在使用这个子类的电子邮件字段和密码字段。 – (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"]; …… …… 密码字段已将secureTextEntry设置为YES ,并且当我第一次input时,颜色如预期的那样是白色的。 然后,如果我点击清除button,将焦点放在电子邮件字段上,然后回到密码字段并开始input,则文本现在变成黑色。 我不知道为什么它会丢失我在drawRect覆盖中设置的颜色。 如果我在电子邮件领域尝试相同的步骤,无论多less次清理和重新聚焦领域,它都会保持白色。 我猜这与安全文本input有关。 任何在这方面的帮助将不胜感激。 谢谢!

UITextFieldinput文本时出现奇怪的行为

要在Google上search这个问题,但不知道我需要写什么,find确切的原因所以我在这里。 ISSUE使用Interface Builder创buildUITextField并运行项目,当我使用iOS Keyboardinput任何值时,这就是发生了什么,我很困惑。 这发生在一个项目和我创造了一个新的一切工作正常。 应用程序在模拟器上启动时的第一次。 然后我使用iOS Keyboardinput单个字符G 然后,我再次使用iOS Keyboardinput单个字符G 再次使用iOS Keyboard单个字符G 再次使用iOS Keyboard单个字符G 这是什么东西在这里下来完全奇怪,但面临这个问题。 您可以查看Youtubevideo 如果有人知道,请分享。 谢谢