Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
484 views
in Technique[技术] by (71.8m points)

ios - Using a storyboard reference to a storyboard in a different project/bundle appears broken

Now, I have a workspace which have two project inside, one is call "ProjectOne" and the other is "ProjectTwo" as follow:

image

They have a storyboard respectively and now I want to connect two storyboard by pressing the "To Project Two" as follow:

image

but when I click the button, it show

"Terminating app due to uncaught exception 'NSInvalidArgumentException', >reason: 'Could not find a storyboard named 'two' in bundle NSBundle 8C6A5FDC9E06/ProjectOne.app> (loaded)'"

Is it possible to do that? I seeking the method for a few days but also no idea...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to use the complete names of the storyboard you are including if your storyboard is in another project/module - this means including the bundle name. Please see the image below for how you would set this up in your storyboard. I have created an example setup with ProjectOne and ProjectTwo the same as your project setup.

enter image description here

The key is the information you put in the Storyboard reference. You need to include the bundle name as well! Just for reference I have included a link to Adding a Storyboard Reference

enter image description here

EDIT

While this works it leads to issues later on as you start to build your storyboard out with various scenes which are backed by view controllers, which now have to be linked to both project targets. More importantly this relationship is hidden in the project's configuration details. A better way for this to work would be to take advantage of the workspace and add a shared folder for the resources that are used by both projects.

enter image description here

Next add the shared folder to the workspace at the same level as ProjectOne and ProjectTwo. Now add a reference to the shared folder to each project by dragging it on to the project files(xcodeproj). This will add the folder to the projects target for you.

enter image description here

Now each project contains a reference to the shared folder, the sharing relationship is now explicitly shown within the project navigator.

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...