我想使擴張的tableview,我用這個例子來創建可擴展的tableview http://www.appcoda.com/expandable-table-view/多重選擇器視圖
我的問題是,當我想創建自定義的tableviewcell類和選擇器視圖的數據源方法,那麼所有的tableview其中包含選擇器視圖沒有不同的值相同,能做些什麼來爲所有的tableview細胞選擇器視圖
這裏設置不同的值單元格是代碼
class CustomTableViewCell: UITableViewCell,UIPickerViewDelegate,UIPickerViewDataSource {
@IBOutlet weak var picker: UIPickerView!
@IBOutlet weak var detailLabel: UILabel!
@IBOutlet weak var mainLabel: UILabel!
var picArr = [String]()
var dic : NSMutableDictionary!
override func awakeFromNib() {
super.awakeFromNib()
dic = NSMutableDictionary()
dic = ["item1":"Height,Width","item2":"Feet,Centimeter"]
picArr = ["Pounds","Kilograms","Stone"]
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
// PickerView Datasource
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
print(component)
return picArr.count
}
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return picArr[row]
}
}
你有固定的值,所以它顯示修復vaue –