简体   繁体   English

从视图即按即按视图控制器无法快速运行

[英]Push To view controller from View is not working in swift

I tried to push to a view controller from a view class using tap gesture action. 我试图使用点击手势操作从视图类推送到视图控制器。 All the below lines are executed, but the control not pushing to respective view controller. 下面的所有行均已执行,但控件未推送到相应的视图控制器。 I need to push to that view controller, but not to set the controller as root view,because i need to navigate back to some other navigated view controller. 我需要推送到该视图控制器,但无需将控制器设置为根视图,因为我需要导航回其他导航视图控制器。 Any one please help me. 任何人请帮助我。

let webViewController = R2WebViewViewController()
currentWindow.rootViewController?.navigationController?.pushViewController(webViewController, animated: true)

try this 尝试这个

(currentWindow?.rootViewController as! UINavigationController).pushViewController(webViewController, animated: true)

Your root must be navVC 您的根目录必须是navVC

currentWindow.rootViewController?.navigationController?

Your problem is that your rootViewController is probably an UINavigationController already, so you should do: 您的问题是您的rootViewController可能已经是UINavigationController了,所以您应该这样做:

let webViewController = R2WebViewViewController()
(currentWindow.rootViewController as? UINavigationController).pushViewController(webViewController, animated: true)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM