uitextfield

UITapGestureRecognizer on a text field not as expected

孤人 提交于 2019-12-20 03:05:52
问题 In my class I have 11 UITapGestureRecognizers in an array textViewRecognizer attached to 11 out of 100 UITextFields in an array boxArray. When a Textfield is tapped containing a UIGestureRecognizer it runs tappedTextView where I try to get the index of the first responder. However, due to some weird ordering in how things are executed, the action function only gives me the first responder of the previous first responder to the one that was just tapped. Also, I have to double tap to even

tvOS UITextField blank after editing

跟風遠走 提交于 2019-12-20 02:27:33
问题 Editing UITextField in tvOS shows a new view where the user can enter in text, and when text entry is done, the user is returned to the previous view. However, I have found that when I return from the text editor, the text I edit does not show up in my text fields. What's going on? tvOS version 9.1 回答1: The reason why it isn't working is because the UITextField is using a non-default background color. Apparently in tvOS, the background color is rendered to the layer after the text has been

Subclassing and overriding UITextField in Monotouch

百般思念 提交于 2019-12-19 19:58:35
问题 I am trying to set the placeholder text for a UITextField to a different color. I have learned that I need to subclass and override drawPlaceholderInRect method. iPhone UITextField - Change placeholder text color (void) drawPlaceholderInRect:(CGRect)rect { [[UIColor blueColor] setFill]; [[self placeholder] drawInRect:rect withFont:[UIFont systemFontOfSize:16]]; } Here is what I have so far, but I just can't figure out how to get it just right. I am confused on the last line as I don't know

Subclassing and overriding UITextField in Monotouch

大憨熊 提交于 2019-12-19 19:56:11
问题 I am trying to set the placeholder text for a UITextField to a different color. I have learned that I need to subclass and override drawPlaceholderInRect method. iPhone UITextField - Change placeholder text color (void) drawPlaceholderInRect:(CGRect)rect { [[UIColor blueColor] setFill]; [[self placeholder] drawInRect:rect withFont:[UIFont systemFontOfSize:16]]; } Here is what I have so far, but I just can't figure out how to get it just right. I am confused on the last line as I don't know

No Method declared with Objective-C Selector for Notification UIKeyboardWillShowNotification and UIKeyboardWillHideNotification

寵の児 提交于 2019-12-19 19:45:09
问题 After the recent update of Xcode, this code that used to work no longer works. Most of the Selector(":") has an auto correction with the exception for this code: override func viewDidLoad() { super.viewDidLoad() NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillShow:"), name:UIKeyboardWillShowNotification, object: nil); NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillHide:"), name:UIKeyboardWillHideNotification,

iOS - Dismiss UIDatePicker presented as inputView

∥☆過路亽.° 提交于 2019-12-19 18:56:17
问题 I have a text field in my UI that when it's selected presents a UIDatePicker instead of the default keyboard, how could I set up a button as to dismiss the picker when the user is done? 回答1: What I do is have my inputView as a custom view which contains a UIDatePicker and a toolbar above it with a 'Done' button wired up to a method that calls a delegate method to tell the object that owns the UITextField to dismiss the "keyboard" by calling resignFirstResponder . 回答2: Create a UIView (namely

Autolayout in UITextField: Auto Layout still required after executing -layoutSubviews

会有一股神秘感。 提交于 2019-12-19 17:34:07
问题 I'm subclassing UITextField to add a label on the left side. I'm using autolayout to layout the label. However, I keep getting this crash: Here's how I am doing my layout code: - (void)updateConstraints { self.segmentLabel.translatesAutoresizingMaskIntoConstraints = NO; NSLayoutConstraint *constraint; constraint = [NSLayoutConstraint constraintWithItem:self.segmentLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeHeight multiplier:1

How to add UITextfield on click of UIButton and make it editable

北战南征 提交于 2019-12-19 12:46:07
问题 I have a UIButton and I am trying to develop an editable UITextField onclick of UIButton. Basically, I want the user to click on the button and edit the text and save it for future use. So currently I have: [notes_button addTarget:self action:@selector(editNote) forControlEvents:UIControlEventTouchUpInside]; I am not sure how to get a popup like UITextField onclick and add UITextField in editNote function. 回答1: Try this. First make your textfield hide on viewdidload - then on button push,

UiTextfield- First letter must be 0

不羁岁月 提交于 2019-12-19 12:04:24
问题 I am using phone number texfield, now i am using this format for texfield (#) ### ### ###, now issue is that i want first character 0 as compulsary, like this (0) 959 554 545, so user enter whatever first character must be typed 0, this is my code func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { let newString = textField.text if ((newString == "") && (newString?.count == 0)){ txtMobileNumber.text = "0" return true

Change default touch events for UITextField

落爺英雄遲暮 提交于 2019-12-19 10:56:30
问题 Alright, so here is what I am trying to do. I have a UITextField. When I single tap it, I want to call one of my methods. When I double tap (tap it twice with 1 finger) it, I want to edit the text field (as though I had single tapped it on a normal UITextField.) I am not sure how to go about this. I was thinking of sub-classing UITextField and trying to intercept the touch event as it is sent, but I can't figure out which methods to override to do this. Which methods should I override and how