在展开分段停止分段后显示警报。如何确保在展开段完成后显示警报?

编程入门 行业动态 更新时间:2024-10-27 14:27:02
本文介绍了在展开分段停止分段后显示警报。如何确保在展开段完成后显示警报?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个从A视图控制器到B视图控制器的展开段。

在B中执行网络操作。操作完成后,响应将显示在A视图控制器中。

我成功地制作了这个结构。但是,有一个问题:

当我尝试显示警报时,它显示但停止了段。如何确保段完成后显示警报。

错误如下:

2016-04-27 14:39:28.350 PROJECT[9100:128844] Presenting view controllers on detached view controllers is discouraged <PROJECT.FeedTableViewController: 0x7a928c00>. 2016-04-27 14:39:28.359 PROJECT[9100:128844] popToViewController:transition: called on <UINavigationController 0x7c12a800> while an existing transition or presentation is occurring; the navigation stack will not be updated.

A:中的展开处理程序

@IBAction func unwindToFeed(segue: UIStoryboardSegue) { jsonArray[rowFromShare!]["ApplicationDataUsers"] = jsonFromShare! tableView.reloadData() ShowErrorDialog("Success", message: successMessageFromShare!, buttonTitle: "OK") } //Error Dialog func ShowErrorDialog(title:String, message:String, buttonTitle:String){ let alert = UIAlertController(title: title, message: message, preferredStyle: .Alert) alert.addAction(UIAlertAction(title: "OK", style: .Default) { _ in }) self.presentViewController(alert, animated: true){} }

展开B中的触发器:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue.identifier == "unwindToFeed"{ let feedTable = segue.destinationViewController as! FeedTableViewController feedTable.rowFromShare = row feedTable.jsonFromShare = jsonToShare feedTable.successMessageFromShare = successMessageToShare } // Get the new view controller using segue.destinationViewController. // Pass the selected object to the new view controller. } A=FeedTableView控制器 B=ShareTableView控制器

如何确保在段完成后显示警报?

推荐答案

如您所见,在展开段完成之前调用unwindToFeed方法。

一种方法是在unwindToFeed方法中设置一个布尔值,然后在viewDidAppear中检查该布尔值,当您知道段已完成时。如果设置了布尔值,则可以显示警报:

@IBAction func unwindToFeed(segue: UIStoryboardSegue) { jsonArray[rowFromShare!]["ApplicationDataUsers"] = jsonFromShare! tableView.reloadData() self.unwinding = true } override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) if (self.unwinding) { self.ShowErrorDialog("Success", message: successMessageFromShare!, buttonTitle: "OK") self.unwinding=false }

更多推荐

在展开分段停止分段后显示警报。如何确保在展开段完成后显示警报?

本文发布于:2023-11-27 20:28:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639492.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   完成后

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!