uipickerview

Change the 2nd and 3rd pickerView acording to what row from the 1st picker is selected

送分小仙女□ 提交于 2021-02-19 07:53:10
问题 I have 3 pickers like this: the 1st one is the generalPicker, the 2nd and 3rd are the same. In the generalPicker, I have an array (menu): ["Length", "Volume", "Mass"] and every time I want to choose, for example Mass from the generalPicker, I want to get in the 2nd and 3rd pickers this array: ["Milligram", "Centigram", "Gram", "Kilogram", "Stone", "Pound", "Ounce"]. Or, if I chose in the generalPicker, let's say, Length, then I want to get in the 2nd and 3rd pickers: ["Millimeter",

Selecting a picker value to lead to a text field, SwiftUI

耗尽温柔 提交于 2021-02-11 17:55:20
问题 Im trying to implement a feature in my app. When I click on my picker: Picker(selection: $profileViewModel.education, label: Text("Education Level")) { ForEach(Education.levels, id: \.self) { level in Text(level).tag(level) } } This takes me to a screen and then I select the value (this is fine - it works as expected) How could I select the value which then takes my to let's say another screen so I can fill in more details regarding the selected value. For example the above picker has a

Add a button to UIPickerView

我是研究僧i 提交于 2021-02-11 17:40:39
问题 How can I add a button to a UIPickerView? Thanks. The result should be like this: 回答1: There's no built-in way. You can just put a button on top of it. I'm guessing that button was just well-designed to look right in that position :) 来源: https://stackoverflow.com/questions/7211996/add-a-button-to-uipickerview

TextInput Field with Pickerview instead of keyboard

Deadly 提交于 2021-02-07 20:21:07
问题 I want to add a pickerview instead of a keyboard for a specific textfield and fill the picker view with content directly in the .m file What is the easiest way to accomplish that? Can I do this directly in the interface builder or do i have to add much code on my own? 回答1: For any Xamarin.iOS developers, here's how to do it in C# public partial class MyViewController : UIViewController { public override void ViewDidLoad() { base.ViewDidLoad(); ConfigurePicker(); } void ConfigurePicker() { var

TextInput Field with Pickerview instead of keyboard

ε祈祈猫儿з 提交于 2021-02-07 20:20:34
问题 I want to add a pickerview instead of a keyboard for a specific textfield and fill the picker view with content directly in the .m file What is the easiest way to accomplish that? Can I do this directly in the interface builder or do i have to add much code on my own? 回答1: For any Xamarin.iOS developers, here's how to do it in C# public partial class MyViewController : UIViewController { public override void ViewDidLoad() { base.ViewDidLoad(); ConfigurePicker(); } void ConfigurePicker() { var

How to use multiple UIPickerViews in one view controller

痴心易碎 提交于 2021-01-28 12:49:32
问题 I am trying to set up 2 UIPickerViews in 1 view controller. I have not been able to find resources that solve my problem. I have tried following the answer from Diavel Rider on How to use 2 UIPickerView's in one View Controller?. I got some errors from that. I have also tried adding tags but was not able to successfully do that. I am using Swift 4. Here is the code of my view controller: import UIKit class FirstViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {

SwiftUI - picker is having freezing when selecting after keyboard is up

╄→尐↘猪︶ㄣ 提交于 2021-01-28 09:51:45
问题 I have a picker: Section(header: Text("About you")) { TextField("About you", text: $profileViewModel.bio) Picker(selection: $profileViewModel.education, label: Text("Education Level")) { ForEach(Education.levels, id: \.self) { level in Text(level).tag(level) } } TextField("Occupation", text: $profileViewModel.occupation) } When I click on the text field, the keyboard appears, which is fine, but when i click on the picker it takes me to the new screen to pick the value and return to the form.

UIPickerView selection array Swift

∥☆過路亽.° 提交于 2021-01-28 05:49:58
问题 Currently, I got my code to work correctly, but the problem I'm having issue with the UIPickerView. Right now, If I select Cameron brand, it goes to var Cameron but if i select Shaffer brand, it still goes to var Cameron. How can I rewrite the code so when I pick a different brand, it select a different array? For example, if I select brand cameron, it select cameron, if i select brand Shaffer, it pick shaffer, etc. class Picker: UIViewController, UIPickerViewDelegate, UITextFieldDelegate {

Reset the value of the 1st component of UIPickerView when component 0 is changed

岁酱吖の 提交于 2020-12-30 04:39:51
问题 I can't figure out how to reset to component 0 the array used in the first component of the PickerView, when component 0 is changed (in order to avoid possible errors due to indexOutOfRange). This is the structure of my data let bananas = ["banana1", "banana2"] let fruitArray = ["banana1" : ["cherry1","cherry2"], "banana2" : ["cherry1", "cherry2", "cherry3"]] func numberOfComponents(in pickerView: UIPickerView) -> Int { return 2 } func pickerView(_ pickerView: UIPickerView,

Reset the value of the 1st component of UIPickerView when component 0 is changed

醉酒当歌 提交于 2020-12-30 04:39:47
问题 I can't figure out how to reset to component 0 the array used in the first component of the PickerView, when component 0 is changed (in order to avoid possible errors due to indexOutOfRange). This is the structure of my data let bananas = ["banana1", "banana2"] let fruitArray = ["banana1" : ["cherry1","cherry2"], "banana2" : ["cherry1", "cherry2", "cherry3"]] func numberOfComponents(in pickerView: UIPickerView) -> Int { return 2 } func pickerView(_ pickerView: UIPickerView,