ra1028 / Former

Former is a fully customizable Swift library for easy creating UITableView based form.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about InlinePickerView

arpit2297 opened this issue · comments

How can I detect whether a user has chosen a particular item in the pickerview? More specifically, when a user chooses an item in the inlinepicker view, I want to invoke a function call and use those results in the function. I tried calling the function in the .OnValueChanged closure but have been getting issues regarding namespace. Can someone give me an example of how to achieve this?

Thanks a lot!

Here is what I have and it works fine.
My only hang up was I didn't have the InlinePicker init with Value, so it was always nil....

        let maxHeartRate = InlinePickerRowFormer<FormInlinePickerCell, Any>() {
            $0.titleLabel.text = "Max Heart Rate"
            $0.titleLabel.textColor = Color.black
            $0.titleLabel.font = self.titleLabelFont
            $0.displayLabel.textColor = Color.black
            $0.displayLabel.font = self.detailLabelFont
            }.configure {
                $0.pickerItems = (70...250).map { InlinePickerItem(title: "\($0) BPM", value: Int($0)) }
                $0.displayEditingColor = Color.grey.darken2
            }

        maxHeartRate.onUpdate { (picker: InlinePickerRowFormer<FormInlinePickerCell, Any>) in
            picker.selectedRow = UserConfig.sharedConfig.maxHeartRate - 70
        }
        maxHeartRate.onValueChanged { (picker: InlinePickerItem<Any>) in
            print(picker.title, picker.value!)
        }

Closing due to age and it's not quite a bug, if you find yourself having any further questions or concerns, feel free to open another issue.