Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

2
UIPickerView not firing didSelectRow
Post Body

Hi all. I'm creating my first picker menu. The idea of my code is the UIPickerView replaces the keyboard (inputView). However when I run my code on simulator, selecting the picker, and then clicking off the text field, the text box stays empty. Is there something I'm missing? From all the examples online I found, there is no need for a 'done' button to confirm. Or is there just something wrong with my Xcode/Simulator? I'm running MacOS 10.14 on VMWare.

Below is my code:

class ViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {

    @IBOutlet weak var sportSelector: UITextField!
    @IBOutlet weak var sportTitle: UITextField!

    //@IBOutlet weak var sportList: UIPickerView!
    //var sports: [String] = [String]()
    let sports = ["Climbing", "Hockey"]

    let sportList = UIPickerView()


    override func viewDidLoad() {
        super.viewDidLoad()
        sportSelector.inputView = sportList

        //Connect Data
        self.sportList.delegate = self
        self.sportList.dataSource = self


        // Do any additional setup after loading the view.
    }



    //Number of columns in picker view
    func numberOfComponents(in pickerView: UIPickerView) -> Int {
        return 1
    }

    //Number of items in picker view
    func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        return sports.count
    }

    //Items in picker view
    func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String?{
    return sports[row]
    }

    //Capture the picker view selection
    func pickerView(_pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
        sportSelector.text = sports[row]
    }  
}

Author
User Disabled User Suspended
Account Strength
0%
Disabled 9 months ago
Suspended 9 months ago
Account Age
12 years
Verified Email
Yes
Verified Flair
No
Total Karma
55
Link Karma
5,091
Comment Karma
27,325
Profile updated: 7 hours ago
Posts updated: 10 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
5 years ago