uitextfield

how to add a UITextField to a CALayer and make it work

旧时模样 提交于 2019-12-13 04:17:44
问题 I searched on google and I found this. but I'm not sure the answer is true. So what I need is to add UITextField into a CALayer and make it work I used this method but its not working [layer addSubLayer:textField.layer]; Any ideas to solve this problem? 回答1: The short answer is, you can't. Layers are lower-level objects. Views have layers, but layers can't have views. If you were to add another view's layer as a sublayer of your current view's layer, the view level would have no knowledge

Objective C: Begin date and end date UIDatePicker

坚强是说给别人听的谎言 提交于 2019-12-13 04:14:10
问题 I have two UIDatePickers and two UITextField . One UIDatePicker and textField show the begin date + time. The second UIDatePicker and textField shows the end date +time. The problem i'm facing is that i need to connect the two DatePickers so that the end date cannot exceed the begin date + time. Also that there cannot be more than 24hours between the begin and end date + time. What do i need to do in order to achieve this? How do i connect the two UIDatePicker , and prevent the dates + time

How to save text temporary in textfield?

本小妞迷上赌 提交于 2019-12-13 04:01:10
问题 I have a little problem, when I have text put in a UITextfield in view controller A and I go to an other view controller and then i go back to view controller A the text in the textfield had disappear. Is there a way to save the text temporary in the textfield? So the text won't disappear when you go to an other view controller. 回答1: when you navigate the page at that time save the data in NSUserDefaults . NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults]; [defaults setObject

How to set UITextField width constraint to have room for a certain string

夙愿已清 提交于 2019-12-13 03:56:35
问题 I have a UITextField that will display floating point values between 0 and 1.0 with 3 digits after the decimal point. So the widest text it will show is something like "0.000". I'd like to set the auto layout width constraint so that the text field always has just enough room to display this value. The code below is close, but does not work. let biggestString = "0.000" let textAttrs = [NSAttributedStringKey.font: myField.font] let size = (biggestString as NSString).size(withAttributes:

Changing Auto Layout Anchor Constrains

余生长醉 提交于 2019-12-13 03:42:04
问题 I have a UITextField , and I'm trying to change its position when the keyboard comes up. More specifically, I want to move the text field up so that it sits just above the keyboard. My code looks something like this let textField = myCustomTextField() override func viewDidLoad() { //set up textfield here //constrains blah blah textField.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -view.bounds.height * 0.05).isActive = true //more constraints } What I want

UITextField contents are empty after popViewControllerAnimated

百般思念 提交于 2019-12-13 03:37:39
问题 In my app I'm using a navigation controller. My problem is, when I go to previous view and then back to my current view, all TextFields in this view are empty. I don't know how to save these values (in textfields) when I navigate through the stack from navigation controller. This is my method where I call popViewControllerAnimated: - (IBAction)swipeBack:(id)sender { [self.navigationController popViewControllerAnimated:YES]; } 回答1: In your previous view's .h file declare a property: @property

Unable to validate added row tableview textField in swift

走远了吗. 提交于 2019-12-13 03:25:36
问题 For all categories i am getting one value from json but For one category i need extra row in tableview, i have added extra row and text in textfield but i am unable to validate its textfield text value. this code: var finalSearchValue : String = "" var finalSearchValueAmnt : String = "" var cell : BillerTableViewCell? added extra row for bcategoryname == "Mobile Postpaid" func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { if section == 0 { self.rowCount =

UITextField randomly reusing text in tableview

徘徊边缘 提交于 2019-12-13 03:18:25
问题 I'm having some issues with my table that has UITextFields in each cell. I notice text is still getting reused randomly in the wrong cells even though I seem to be saving it correctly. - (void) textFieldDidEndEditing:(UITextField *)textField{ if (textField == temperatureTextField){ [self.vitalsDictionary setObject:self.temperatureTextField.text forKey:@"temperature"]; } else if (textField == pulseTextField){ [self.vitalsDictionary setObject:self.temperatureTextField.text forKey:@"pulse"]; }

Can't get UITextField to populate when using .currency format of NumberFormatter()

牧云@^-^@ 提交于 2019-12-13 02:59:11
问题 I borrowed and modified some code from SO to solve a problem where I was trying to format text that I inputted into my UITextField s. If I use the .decimal numberStyle of NumberFormatter it works (adds a comma where I need it) but if I use .currency I can't type anything once I run the app. The UITextField will not populate. I've tried playing around with the locale and that doesn't seem to solve anything. All I want to do is to show the user the "$" sign in front of the number they type as

UITextField in inputAccessoryView won't becomeFirstResponder

萝らか妹 提交于 2019-12-13 02:15:40
问题 I have a view called songInfoView with 3 UITextFields and a UIButton. I create a temp UITextField in the parent view to bring up the keyboard and assign songInfoView as the inputAccessoryView. This works as expected. Then, I try to set a text field in songInfoView as first responder. The cursor moves to this field, but when I try to type, nothing happens. I can tap on the text field and type as expected, but I want it to work without having to tap on it. Am I missing something? Am I doing