uitextfield

Adding input accessory view to UITextField while keyboard is visible

删除回忆录丶 提交于 2019-12-06 01:52:26
问题 I would like to add an input accessory view to a UITextField while it is the first responder, i.e. showing the keyboard. Apparently, assigning a UIView to the inputAccessoryView property in this state doesn't display this view. I have to first dismiss the keyboard and re-select the UITextField . Is there a way to add an input accessory view without dismissing and re-selecting? 回答1: If possible only assign the inputAccessoryView once. If you need it to be customized, and can only determine how

UIViewControllerHierarchyInconsistency crashes app only in iOS 8 and Xcode 6

て烟熏妆下的殇ゞ 提交于 2019-12-06 01:43:23
问题 i have an app which work fine in iOS 7 and Xcode 5. As soon as I updated it to iOS 8 and Xcode 6 it crashes when app try to slide up UIDatePicker in the view when a textField is tapped. I am using storyboard. Anybody has idea why? i have read upon this but its for Xib. App crashes on IOS 6 - UIViewControllerHierarchyInconsistency please help thanks my code: - (void)textFieldDidBeginEditing:(UITextField *)textField { //set picker color start [self.myDatePicker setBackgroundColor:[UIColor

Disable Keyboard for UITextfield

匆匆过客 提交于 2019-12-06 01:40:26
I'm wondering how to disable the inputview of a UITextfield. Setting textField.inputView = nil; or [textField setInputView:nil] in ShouldBeginEditing doesn't do anything, and using the userInteraction property removes the ability to interact with the field. Ideally, I'd like to remove both the cursor and the keyboard while still being able interact with and switch between textfield methods, using ShouldBeginEditing and ShouldEndEditing. Is there any way to accomplish this? You should do this: myTextField.inputView = UIView.new; //Empty UIView Setting it to nil just means the default keyboard

UITextField inside UITableViewCell: becomeFirstResponder in didSelectRowAtIndexPath

≡放荡痞女 提交于 2019-12-06 01:04:21
问题 I am currently trying to get this working. Any help is appreciated. I have a custom UITableViewCell that has a UITextField inside. When I select the table cell, I would like to make the UITextField first Responder. However [textField becomeFirstResponder]; returns false . - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath]; UITextField *textField; for (UIView *view in

UITextField — Adding UIView for leftView - Can't get Focus

余生颓废 提交于 2019-12-06 00:34:55
The UITextFields in my app have placeholder text defined (in Interface Builder), and I cannot cause these fields to acquire focus (i.e. show the keyboard and allow editing) when I tap on the area occupied by the placeholder text. If I tap on the textfields in an area just outside the that of placeholder text (though still within the bounds of the textfiled itself), it acts as normal (i.e. the keyboard pops up and I can edit the content of the textfield). How can I fix this? Thanks. EDIT 1 Ok, I think I've got it. I'm also setting a blank view to the "leftView" property of these UITextFields.

Some UITextfields don't respond in iOs6

天大地大妈咪最大 提交于 2019-12-06 00:27:57
问题 Since updating to iOS 6 I have this weirdest bug when trying to make an UITextField or UITextView firstResponder. ...it doesn't work. I am not able to select the field or view and bring up the keyboard, nor is there a cursor or anything. The weirdest thing is that it is only not working for SOME fields, other ones in different viewcontrollers work without trouble. I have: [self.window makeKeyAndVisible]; self.window.rootViewController = self.viewController; in my appDelegate. It worked and

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

雨燕双飞 提交于 2019-12-06 00:15:10
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 text box with initial string "Clear Text" . I watched the following tutorial on youtube. The

How to resign textfield as first responder in uitableviewcell

只愿长相守 提交于 2019-12-06 00:09:47
问题 I use this code to resign my UITextField as firstResponder when using a standard UIView . But I now have UITextField in my UITableViewCell in a UITableView , and the code does not resign the textfield as first responder when I click outside of the textField. Any ideas how to make this work? - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; if ([self.temperatureTextField isFirstResponder] && [touch view] != self

Toggling UITextField to show and hide in Swift

泄露秘密 提交于 2019-12-05 22:52:50
问题 I'm trying to hide a username textfield when toggling over to login from register and show it again when toggling back. I'm programming the UI in and I would like to figure out how you can hide a textfield, I'm new to swift and I think there are two places I could insert code to hide the username textfield. If not please tell me, Thanks! Image of what I am trying to hide. Here in the UISegmentedControl lazy var loginRegisterSegmentControl: UISegmentedControl = { let sc = UISegmentedControl

Center align placeholder in textfield

喜你入骨 提交于 2019-12-05 22:18:47
问题 I know this question been asked many times but as drawinrect deprecated and I need this in ios 8.As I have a textfield and I need the placeholder in center align and rest of the test left align.Please help me out. 回答1: Create and connect IBOutlet to your textField. In YourViewController.m @interface YourViewController () <UITextFieldDelegate> @property (weak, nonatomic) IBOutlet UITextField *txt; In your viewDidLoad self.txt.delegate=self; self.txt.textAlignment=NSTextAlignmentCenter; Write