-1
DatePicker如何在TableView中單擊某個特定單元格時出現。此外,我需要一個完成按鈕在你TableViewController使用DatePicker在Swift中調用didSelectRowATIndexPath
DatePicker如何在TableView中單擊某個特定單元格時出現。此外,我需要一個完成按鈕在你TableViewController使用DatePicker在Swift中調用didSelectRowATIndexPath
後diasapper的DatePicker:
var chosenNumber = 0
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
//set your chosenNumber here based on your the cell that was clicked
chosenNumber = 1
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
let controller = segue.destinationViewController as! ViewController
//the startRow variable in the ViewController with the picker is set to the same value as the chosenNumber
controller.startRow = chosenNumber
}
與拾取您的ViewController
:
var startRow = 0
override func viewDidLoad() {
//the selected item in the spinner will the value of startRow
spinner.selectRow(startRow, inComponent: 0, animated: false)
}
隱藏微調一個按鈕被點擊時:
@IBAction func buttonClicked(sender: UIButton) {
spinner.hidden = true
}
請發表您迄今嘗試過的代碼。 – random