Answer the question
In order to leave comments, you need to log in
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")
}
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question