我会给我要那么它不是那么混乱的一个例子:如何通过无需再次重新加载视图中移动如果就回国了斯威夫特
例子:
比方说,我有一个地图每次我的用户动态滚动3个注释都会添加。现在我在地图下面有一个按钮,当我按下按钮时,我会转到另一个viewController,按照我想要的操作并返回到带有地图的viewController,现在我想查找我的地图有的所有注释,而不是重新加载视图所有。
我用这个功能,我做出viewControllers之间移动:
func move(identifier: String , viewController : UIViewController) -> Void {
let mstoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc: UIViewController = mstoryboard.instantiateViewControllerWithIdentifier(identifier)
viewController.presentViewController(vc, animated: true, completion: nil)
}
我也试过这样:
let vc = self.storyboard?.instantiateViewControllerWithIdentifier("view") as? MyViewcontroller
self.presentViewController(vc!, animated: true, completion: nil)
这两个当我使用它们出现的viewcontroller
是调用viewDidload
所以它就像它第一次出现一样。
又如tabBarViewController
如果您在通过标签没有重新加载导航通知(仅函数被调用为viewDidAppear
)
编辑
如果你正在使用'presentViewController',那么你可以在该控制器上执行'dismiss(animated:true,completion:nil)'来返回到前一个,而不用重新加载 – mursang