[英]What happens to root view controller in ios / swift
不,您不必重新实例化它。 您可以像这样从UINavigationController
访问所有当前的UIViewControllers
self.navigationController?.viewControllers
这将返回一个[UIViewController]
。 如果要获取viewController,则它位于index = 0
。 如果您想回到root
,可以致电
self.navigationController?.popToRootViewControllerAnimated(true)
我将添加它作为评论,只是我没有足够的观点。 要回答您的问题-您不必担心重新实例化以前的View Controller。 如果使用的是presentViewController:animated:completion
方法,则可以使用过渡后设置的UIViewController类中的presentedViewController
和presentingViewController
属性。
下面的开发人员链接将帮助您根据用例更好地决定如何处理View Controllers转换-
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.