【问题标题】:Xcode Swift perform segue with alertXcode Swift 使用警报执行 segue
【发布时间】:2017-09-30 11:25:59
【问题描述】:

我有三个 ViewController。当您单击出现警报的Ok 按钮时,我想执行从ThirdViewControllerSecondViewController 的转换。我已经尝试过使用此代码:

alert.addAction(UIAlertAction(title: "Ok!", style: UIAlertActionStyle.default, handler: { action -> Void in
     self.performSegue(withIdentifier: "ThirdViewControllerSegueBack", sender: self)
}))

问题是SecondViewController 的新窗口出现了,所以当我点击导航栏上的back 时,它会将我带回到ThirdViewController。我希望它显示FirstViewController

【问题讨论】:

标签: swift xcode uinavigationcontroller segue uialertaction


【解决方案1】:

在 SecondViewController 中,您必须创建 Unwind segue

@IBAction func unwindToController2(segue:UIStoryboardSegue) { } 

ViewController3 中的情节提要从 ViewController 拖动到退出 Button 并添加 segue。为其添加标识符,并调用 UIAlertController

【讨论】:

  • @lolinger2001 不客气)请检查答案是否正确)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-02-29
  • 1970-01-01
  • 1970-01-01
  • 2015-01-24
  • 2018-12-05
  • 1970-01-01
  • 2023-03-15
相关资源
最近更新 更多