import UIKit
class PickerViewController: UIViewController,UIPickerViewDelegate,UIPickerViewDataSource {
@IBOutlet weak var emojiPicker: UIPickerView!
override func viewDidLoad() {
super.viewDidLoad()
emojiPicker.dataSource = self
emojiPicker.delegate = self
}
//pickerViewデータ行数
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return emojis.count
}
//pickerView列数
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
//pickerViewデータ内容
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return emojis[row]
}
//pickerView選定事件
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
<#code#>
}
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme