UIPickerView Ghost Image

时间:2016-08-19 08:15:46

标签: swift uipickerview

我正试图在我的快速代码中使用选择器视图,幸运的是我可以运行。但每次加载程序时,我的选择器视图都会创建一个自己的鬼影。为什么会这样?我是否需要对代码进行任何调整? here

import Foundation
import UIKit

class ViewTwo: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {

    @IBOutlet weak var pickerMenSplit: UIPickerView!

    //var menPickerSplit: [String] = [String] ()
    var menPickerSplit = ["A", "B", "C", "D", "E"]
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        //Connect Data:
        pickerMenSplit.delegate = self
        pickerMenSplit.dataSource = self

        //Input data into the Array:


    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    //the number of columns of data
    func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
        return 1
    }

    //the number of rows of data
    func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        return menPickerSplit.count
    }

    //the data to return for the row and component (column) that's being passed in
    func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
        return menPickerSplit[row]
    }

}

1 个答案:

答案 0 :(得分:0)

您是否尝试过清洁项目? cmd + shift + k,如果不起作用,请尝试从模拟器中删除您的应用,然后尝试再次运行它。