在我的導航欄中,我添加了一個用於添加新對象的「+」。但在程序在按下'+'(第1步)時切換到新的ViewController之前,我希望用戶輸入如第2步所示的輸入。但是我不知道該序列被調用的是什麼?或如何做到這一點。segue前用戶選擇
我期待着您的來信:)。
步驟1:
在我的導航欄中,我添加了一個用於添加新對象的「+」。但在程序在按下'+'(第1步)時切換到新的ViewController之前,我希望用戶輸入如第2步所示的輸入。但是我不知道該序列被調用的是什麼?或如何做到這一點。segue前用戶選擇
我期待着您的來信:)。
步驟1:
1)從本視圖控制器添加SEGUE到下一個視圖控制器和給它一些標識符(假設 「gotoNext」 )。
2)在 「+」 行動,打開使用UIAlertViewConroller(參考link)動作片:
let alertController = UIAlertController(title: nil, message: "This is my message.", preferredStyle: .ActionSheet)
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (action) in
// ...
}
alertController.addAction(cancelAction)
let OKAction = UIAlertAction(title: "OK", style: .Default) { (action) in
// ...perform any functionality here (e.g. - perform your segue here)
performSegueWithIdentifier("gotoNext", sender: self)
}
alertController.addAction(OKAction)
self.presentViewController(alertController, animated: true) {
// ...
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if "gotoNext" == segue.identifier {
// this is where you can pass any data to the next view controller.
}
}
希望這有助於你。
它已經修復。我只需要知道'Alert'這個名字:-P。 但是,謝謝你的好解釋! – Grumme
@Jakob - 哦!太棒了!別客氣 :) –
不要直接從「+」使用segue。使用動作處理程序,呈現UIAlertView並在警報視圖中的操作中觸發所需的segue – Paulw11
太棒了。謝謝Paulw11! – Grumme