标签云

微信群

扫码加入我们

WeChat QR Code

I'm trying to use an AlertController to allow the user to return to the main menu, if a certain calculated value is exceeded. I know that using a simple segue will lead to memory problems.Is there a way to use the popToRootViewController method in this situation instead of simply using a segue? The compiler yells at me (no doubt for good reasons), but gives me no useful suggestions. I know the problem stems from the handler for the Abort Fit action.Can someone point me in the right direction?override func viewDidLoad() {super.viewDidLoad()if deltaK > 2.25 {var helpAlert = UIAlertController(title: "Stop!", message: "Dueto high toricity, the fit should be aborted.", preferredStyle: .Alert) helpAlert.addAction(UIAlertAction(title: "Abort Fit", style: UIAlertActionStyle.Default, handler: { action in self.navigationController.popToRootViewControllerAnimated(true)) }) helpAlert.addAction(UIAlertAction(title: "Continue", style: UIAlertActionStyle.Default, handler: nil))self.presentViewController(helpAlert, animated: true, completion: nil)}


The biggest problem here is trying to present a view controller in the midst of viewDidLoad()...

2019年04月19日21分00秒

Unwind segues might be what you're looking for.

2019年04月19日21分00秒