简体   繁体   English

如何从情节提要中加载Xib文件?

[英]How to load a xib file from a storyboard?

I am new to iOS programming and I am working on a project which will use both XIB files and storyboard. 我是iOS编程的新手,正在从事一个同时使用XIB文件和情节提要的项目。 I have two modules in it basically. 我基本上有两个模块。 First module is made from XIB files which also runs independently. 第一个模块由XIB文件制成,该文件也可以独立运行。 I have made another module using storyboard and I had to integrate these two independently running modules. 我使用情节提要制作了另一个模块,并且我必须集成这两个独立运行的模块。 The screen of my first module which I want to connect to my storyboard is a subclass of UIViewController and I was able to do that with the help of stackoverflow ( How to load a storyboard from a XIB file? ) by creating an object of UIStoryBoard. 我要连接到我的情节提要的第一个模块的屏幕是UIViewController的子类,我可以通过创建UIStoryBoard对象在stackoverflow( 如何从XIB文件加载情节提要 )的帮助下做到这一点。 Now my application is able to go to the storyboard but I can't come back to my first module which is made up of XIB files. 现在我的应用程序可以转到情节提要,但是我无法返回由XIB文件组成的第一个模块。

Please let me know how can I connect to the same instance of the last screen of the first module through which storyboard is called so that I can move back and forth through these views easily. 请让我知道如何连接到调用情节提要的第一个模块的最后一个屏幕的同一实例,以便我可以轻松地在这些视图之间来回移动。 Connecting to the same instance of the XIB file is important because it is a chat screen and when I come back to this screen, I would like to get back to the chat where I had left it and also when I come back to the storyboard (by clicking a button on the chat screen) I have a slider on the screen which should display the value which the user must have chosen when they were on this screen last time. 连接到XIB文件的同一实例非常重要,因为它是一个聊天屏幕,当我返回此屏幕时,我想回到我离开该文件的聊天室,以及回到故事板(通过单击聊天屏幕上的按钮),我在屏幕上有一个滑块,该滑块应显示用户上一次在该屏幕上时必须选择的值。 I guess creating a new object should give me a new screen which won't work in this situation. 我猜创建一个新对象应该给我一个新的屏幕,在这种情况下不起作用。 This kind of mechanism works well within storyboard with the use of segue where we can define both source and destination view controller. 这种机制通过使用segue可以在情节提要中很好地工作,我们可以定义源视图控制器和目标视图控制器。

Please help me achieve the same in my situation. 请帮助我达到我的情况。

Please also check the screen shots of the XIB file and the storyboard which I want connected. 还请检查XIB文件和我要连接的情节提要的屏幕截图。

Thanks. 谢谢。 在此处输入图片说明

将nib文件转换为情节提要,这将帮助您更轻松地管理应用程序。

Well in your case, what i see is from nibs is that there is a navigation controller in storyboard and also there will be a root view controller navigation controller from xib files. 在您的情况下,我从笔尖看到的是情节提要中有一个导航控制器,而且xib文件中还将有一个根视图控制器导航控制器。 Well the navigation controller stack has all VCs you pushed into and you can get back it in different ways. 导航控制器堆栈具有您已放入的所有VC,您可以通过不同的方式取回它。

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

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