Pickerview显示问号而不是数据

时间:2017-01-18 08:39:14

标签: ios swift3

使用swift 3.下面的代码并没有用合法数据填充选择器。它填充问号,而不是第1项第2项第3项第4项第5项第6项。 我有什么问题?请注意使用swift 3。

import Foundation
import Alamofire
import UIKit
import CoreLocation
import MapKit
import Kingfisher
import DropDown
class LandmarkController: UIViewController,UIPickerViewDelegate, UIPickerViewDataSource  {
    @IBOutlet weak var nameTextField: UITextField!
    @IBOutlet weak var Open2: UIBarButtonItem!
    @IBOutlet weak var pickerView: UIPickerView!
    @IBOutlet weak var latitudeTextField: UITextField!
    @IBOutlet weak var longitudeTextField: UITextField!
    @IBOutlet weak var descriptionTextField: UITextField!
    @IBOutlet weak var arabicNameTextField: UITextField!
    var varView = Int()
    var pickerData: [String] = [String]()
    var selected = 0
    var manager: SessionManager?
    override func viewDidLoad() {
        super.viewDidLoad()
        Open2.target = self.revealViewController()
        Open2.action = #selector(SWRevealViewController.revealToggle(_:))      self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
        print("new new new count stack")
        if let nav = self.navigationController {
            var stack = nav.viewControllers
        }
        self.pickerView.delegate = self
        self.pickerView.dataSource = self
        pickerData = ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6"]
    }
    // The number of columns of data
    func numberOfComponents(in pickerView: UIPickerView) -> Int {
        return 1
    }
    func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        return pickerData.count
    }
    func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
        return pickerData[row]
    }
    func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

0 个答案:

没有答案