首页 > 解决方案 > 如何从 viewcontroller.swift 文件导航到 *.storyboard 文件中的相应场景?

问题描述

Xcode 中是否有一种方法(组合键、上下文菜单)可以从自定义 UIViewController(AViewController.swift例如)文件快速导航到情节提要中的屏幕,该屏幕已AViewController.swift在身份检查器选项卡中显示为自定义类?

标签: iosswiftxcode

解决方案


您需要在情节提要的身份检查器中设置情节提要 ID。然后推动:

let vc = storyBoard.instantiateViewController(withIdentifier: identifier)
vc.modalPresentationStyle = .fullScreen
self.navigationController?.pushViewController(vc, animated: true)

标识符是故事板ID

或者您可以通过以下方式呈现它:

let vc = storyBoard.instantiateViewController(withIdentifier: identifier)
vc.modalPresentationStyle = .fullScreen
self.present(vc, animated: true)

推荐阅读