【发布时间】:2015-07-05 17:06:29
【问题描述】:
在我的 iPad 应用程序中,我有一个 UIViewController 和一个打开 modalView 的按钮。
@IBAction func showPostCommentViewController(sender: AnyObject){
let modalView = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("PostCommentViewController") as! PostCommentViewController
modalView.modalTransitionStyle = UIModalTransitionStyle.CoverVertical
modalView.modalPresentationStyle = UIModalPresentationStyle.FormSheet
modalView.delegate=self
self.presentViewController(modalView, animated: true, completion: nil)
}
当我使用dismissViewControllerAnimated 关闭modalView 时,我想“刷新”我的视图控制器(因为我添加了新内容)。但由于模态视图是“表单”样式,因此不会调用 viewDidAppear 或 viewWillAppear。
我尝试使用 setNeedsDisplay,但它不起作用。
我不知道该怎么做。
【问题讨论】:
-
你想要发生什么? setNeedsDisplay 可能会更新布局和类似的东西,但标签等的内容不会改变,你必须明确地改变它们。你到底想做什么?
-
您可以在“PostCommentViewController”创建一个委托,该委托将在视图本身消失时创建。然后在被调用者处,您可以定义要使用特定委托执行的任何操作
标签: ios swift uiviewcontroller setneedsdisplay uimodalpresentationstyle