快速选择器视图与数字显示问号

时间:2017-09-16 03:50:54

标签: arrays swift uipickerview

我在我的应用程序中添加了一个选择器视图,并将其设置为一个数字数组。当我运行应用程序时,我看到的只是问号。

有谁知道问题是什么?我也尝试使用Int类型并收到相同的结果。

这是我的代码。

import UIKit
import Firebase
import FirebaseDatabase
import FirebaseStorage

class myViewController: UIViewController, UIPickerViewDelegate,UIPickerViewDataSource {
    @IBOutlet weak var settings: UIBarButtonItem!
    @IBOutlet weak var myTextField: UITextField!
    @IBOutlet weak var enterExit: UISegmentedControl!

    @IBOutlet weak var dayLabel: UILabel!
    @IBOutlet weak var pickerView: UIPickerView!
    @IBOutlet weak var daysTextField: UITextField!

    let numbers = [1,2,3,4,5,6,7,8,9,10,11,12,13,14]
    var hhh = Int()
    let seconds = 60.0

    func numberOfComponents(in pickerView: UIPickerView) -> Int {
        return 1
    }

    private func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> Int? {
        return numbers[row]
    }

    func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        return numbers.count
    }

    func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
        var days = numbers[row]
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        self.pickerView.delegate = self
        self.pickerView.dataSource = self

enter image description here

1 个答案:

答案 0 :(得分:2)

您的问题如下:

ListView

此方法不应该是私有的,并且应该具有正确的签名。此委托方法需要返回可选的map_initialize(); // load map function map_initialize(){ var mapOptions = { center: new google.maps.LatLng(37.286172, -121.80929), zoom: 8, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); var myLatlng = new google.maps.LatLng(37.286172, -121.80929); var marker = new google.maps.Marker({ position: myLatlng, map: map, title: 'A Customized InfoWindow Marker' }); var infoBubble = new InfoBubble({ maxWidth: 300 }); var div = document.createElement('DIV'); div.innerHTML = 'Hello'; infoBubble.addTab('Tab 1', div); infoBubble.addTab('Tab 2', "1234"); //Add event clic into Tab 1. If click in Tab 1 show alert. google.maps.event.addListener(marker, 'click', function() { if (!infoBubble.isOpen()) { infoBubble.open(map, marker); } }); } ,而不是可选的private func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> Int? { return numbers[row] }

String