Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何获取故事板的字符串名称?_Ios_Swift_Storyboard - Fatal编程技术网

Ios 如何获取故事板的字符串名称?

Ios 如何获取故事板的字符串名称?,ios,swift,storyboard,Ios,Swift,Storyboard,我已经看了以下内容,但没有任何指导: 根据以下答案,我正在尝试使用我的故事板从远程通知打开特定的视图控制器: let mvc=MainViewController() 让storyBoardNameString=mvc.storyboard// 我的同事刚刚告诉我,这是没有扩展名“.storyboard”的文件名。问候 尝试以下代码,它可能会对您有所帮助。 let mvc = MainViewController() let storyBoardNameString = mvc.restor

我已经看了以下内容,但没有任何指导:

根据以下答案,我正在尝试使用我的故事板从远程通知打开特定的视图控制器:

let mvc=MainViewController()

让storyBoardNameString=mvc.storyboard// 我的同事刚刚告诉我,这是没有扩展名“.storyboard”的文件名。问候

尝试以下代码,它可能会对您有所帮助。

let mvc = MainViewController()
let storyBoardNameString = mvc.restorationIdentifier!//it will give identifier
let storyboard = UIStoryboard(name: storyBoardNameString , bundle: nil) 
storyboard.instantiateViewControllerWithIdentifier("some-view-controller")

也许我的答案不适合你的问题,但你可以看一看并思考一下

创建有效负载格式,并使用它创建特定的UIViewController

let payload = ["storyboard" : "StoryboadNameYouWant", "viewcontroller" : "ViewControllerName", "parameters" : "YourParameters"]


func handlePayload(payload: Dictionary<String, String>) {
     let storyboard = UIStoryboard(name: payload["storyboard"]!, bundle: nil)
     let vc = storyboard.instantiateViewControllerWithIdentifier(payload["viewcontroller"]!)
     // present vc
}
let payload=[“故事板”:“StoryboadNameYouWant”,“viewcontroller”:“ViewControllerName”,“parameters”:“YourParameters”]
func handlePayload(有效负载:字典){
let storyboard=UIStoryboard(名称:负载[“storyboard”]!,捆绑包:nil)
让vc=storyboard.instantialeviewcontrollerwhiteIdentifier(有效负载[“viewcontroller”]!)
//当前vc
}

如果您可以从
mvc
对象中获取
情节提要
,则不需要为其命名。你已经有了
情节提要
。这可能是一个毫无意义的问题,但我想我必须在
mvc
上使用一个viewController来访问
mvc
正确吗?这不会改变一个事实,即如果你已经从中实例化了任何视图控制器,你不需要情节提要的名称。我知道,但它仍然回答了最初的问题:)
let payload = ["storyboard" : "StoryboadNameYouWant", "viewcontroller" : "ViewControllerName", "parameters" : "YourParameters"]


func handlePayload(payload: Dictionary<String, String>) {
     let storyboard = UIStoryboard(name: payload["storyboard"]!, bundle: nil)
     let vc = storyboard.instantiateViewControllerWithIdentifier(payload["viewcontroller"]!)
     // present vc
}