V
V
Vlad Bazarov2016-04-27 00:08:50
Apple Xcode
Vlad Bazarov, 2016-04-27 00:08:50

How to connect the protocol to the Picker View if it is not on the start page?

Such a problem.
You need to add protocols(UIPickerViewDelegate, UIPickerViewDataSource) for Picker View to make it work. At the same time, the Picker View itself is not on the start page, which is why an error is generated during compilation, since the "self" attribute is used (This, as I understand it).
Here is the code:

class ViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {

@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var pickerView: UIPickerView!
let array = ["One", "Two"]

override func viewDidLoad() {        
    // Do any additional setup after loading the view, typically from a nib.
    super.viewDidLoad()

    pickerView.delegate = self
    pickerView.dataSource  = self
    self.imageView.image = UIImage(named: "1club")

}

.......
Does anyone know how to deal with this?
In any case, thanks for the help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
ManWithBear, 2016-04-27
@ManWithBear

Protocols have mandatory methods that must be implemented. Which you don't seem to be doing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question