uitextfield

UIScrollView not scrolling with UItextfields

僤鯓⒐⒋嵵緔 提交于 2019-12-02 02:50:56
I am making a normal view where users can update their profiles. I followed these steps to make that view Created a new UIViewController with xib file Added a UIScrollView in super view Added almost 9 UITextField and 1 small UIWebView Satisfied Autolayout constraints like top UITextField will have top, left, right and height constrains and same for all the following controls but last UITextField have top, left, right, bottom and height constraints. Now all the constraints are applied and satisfied but when I run the view and then try to scroll by dragging UITextField then scrollview is not

Design Approach for Subclassing UITextField with default behaviors in delegate methods

亡梦爱人 提交于 2019-12-02 02:34:47
问题 I have subclassed the UITextField class so I can provide some built-in functionality for my application. I've changed the appearance to provide only an underline border for the UX design. Also, I want to use this control in situations where there is a picker (pick list, date / time picker). In these cases, I want to prevent editing BUT I still need to respond to touch events. To do this, I've added inspectable properties to control it from IB. I can easily prevent the copy/paste menu from

Default parameter values error: “instance member cannot be used on type viewcontroller”

≯℡__Kan透↙ 提交于 2019-12-02 02:34:11
In my view controller: class FoodAddViewController: UIViewController, UIPickerViewDataSource, UITextFieldDelegate, UIPickerViewDelegate { let TAG = "FoodAddViewController" // Retreive the managedObjectContext from AppDelegate let managedObjectContext = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext @IBOutlet weak var foodName: UITextField! @IBOutlet weak var foodPortion: UITextField! @IBOutlet weak var foodCalories: UITextField! @IBOutlet weak var foodUnit: UILabel! @IBOutlet weak var unitPicker: UIPickerView! @IBOutlet weak var unitPickerViewContainer:

UITapGestureRecognizer on a text field not as expected

江枫思渺然 提交于 2019-12-02 02:30:41
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 select the text field I was going for! I need to use the tap function and not the text delegates so this has

Decimal point in UIKeyboardTypeDecimalPad can't be used in mathematical calculation

别等时光非礼了梦想. 提交于 2019-12-02 01:34:06
I am using the keyboard type: UIKeyboardTypeDecimalPad for two UITextField objects. When trying to perform an addition, I get different results depending on the current locale: Case 1: US Format: the decimal point appears as . as expected. If I add 12.3 (text field 1) + 12.3 (text field 2), the answer will be 24.6. That's what I want. But: Case 2: Egypt Format: the decimal point appears as , . If I repeat the same calculation the answer will be 24. The decimal portion is ignored. Is there a fix for that? Note: I used the [textField.text floatValue] method. magma Because floatValue does non

How can we keep a text field's font size relative to the screen size?

限于喜欢 提交于 2019-12-02 01:25:09
I have a text field and I have given it a regular font with 13 px in size. But I want the font size to increment with respect to screen size. Thanks. You can calculate the font size based on the screen's dimensions. let baseWidth: CGFloat = 320 // the width of the screen where you want to use 13pt let fontSize = 13 * (UIScreen.main.size.width / baseWidth) let font = UIFont(name: "HelveticaNeue", size: fontSize) You can simply do this by checking, Automatically Adjusts Font in the Attributes Inspector 来源: https://stackoverflow.com/questions/46176240/how-can-we-keep-a-text-fields-font-size

Add a prefix to UITextField

梦想的初衷 提交于 2019-12-02 01:22:01
I want a '$' Sign in the text field which cannot be erased. A user should be able to enter values after it and if he presses backspace it should only erase the value he entered. The reason I can't use UILabel before it is because the text in UITextfield is center aligned and it grows to either side as the user enters values. Please provide any solution Set the text field's text to "$" initially. Set the text field's delegate to some object of yours (probably the view controller containing it). Implement -textField:shouldChangeCharactersInRange:replacementString: and return NO if the proposed

UITextView issue with ActionSheetStringPicker Picker view

半城伤御伤魂 提交于 2019-12-02 01:13:54
Check 3 screenshots here first. Screenshot 1 : Subject is UITextview field. When I tap on subject text field normal keyboard will come. There is no problem here now. Screenshot 2 : Priority is UITextfield view. Here I use UIActionsheet Picker view. When I click on Priority textfield picker will appear as shown in screenshot. This is also working fine. My Problem : When I click Priority textfield directly from Subject textview by scrolling without using done button or next button from keyboard. Then following issue is arriving. or when I move UITextview to other any other Text Field like in

How to customize numeric input for a UITextField?

大憨熊 提交于 2019-12-02 00:48:20
I have a UITextField (that represents a tip value) in my Storyboard that starts out as $0.00 . If the user types an 8 , I want the textField to read $0.08 . If the user then types a 3 , I want the textField to read $0.83 . If the user then types 5 , I want the textField to read $8.35 . How would I go about changing the input to a UITextField in this manner? You can do this with the following four steps: Make your viewController a UITextFieldDelegate by adding that to the class definition. Add an IBOutlet to your textField by Control -dragging from the UITextField in your Storyboard to your

How to add a method to UITextField & UITextView?

坚强是说给别人听的谎言 提交于 2019-12-01 22:58:21
I want to put something like this in a method for UITextField & UITextView . - (void)changeKeyboardType:(UIKeyboardType)keyboardType { paymentTextView.keyboardType = UIKeyboardTypeAlphabet; [paymentTextView resignFirstResponder]; [paymentTextView becomeFirstResponder]; } How do I do this? I know I can create categories for both UITextField & UITextView but is it possible to do it in one shot? By one shot, I mean add it to both classes with one protocol instead of making two categories, one for UITextView & one for UITextField . I've heard a protocol is similar to a Ruby module, but in a Ruby