2016-10-24 59 views

回答

1

後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 
     } 
相關問題