我们可以在故事板中使用xib文件吗?

时间:2021-04-13 13:28:43

Actually I have two question related to storyboard,

实际上我有两个关于故事板的问题,

  1. Whether I can reuse my xib file which I have created earlier in Storyboard as it is or I have to copy contains from xib to storyboard?If yes then how?
  2. 是否可以重用我之前在故事板中创建的xib文件,或者我必须从xib复制到故事板?如果是的,那么如何?
  3. Can I use both storyboard and xib in single project or if I am using storyboard I cannot use xib to create viewcontroller?
  4. 我可以在单个项目中同时使用storyboard和xib吗?或者如果我使用storyboard,我不能使用xib来创建viewcontroller?

Thanks in advance!

提前谢谢!

1 个解决方案

#1


2  

Storyboard and nib files can be used in the same project without issue. You can instantiate a VC with nib name just as easily with a storyboard based VC as you can otherwise. The one piece of advice I would give you is if feasible, convert nibs over to storyboard just so the app is easier to manage later on. If you have a legacy app with several nibs, this might not be very time effective, but if you have only a small number (less than 5 I would say), I would make the time investment to have them all in a single storyboard.

故事板和nib文件可以在同一个项目中使用,没有问题。你可以用nib的名字来实例化一个VC,就像你可以用一个基于故事板的VC一样。我给你的一条建议是,如果可行的话,把nib转换到故事板,这样应用程序就会更容易管理。如果您有一个带有几个nib的遗留应用程序,这可能不是很有效的时间,但是如果您只有一个小的数字(小于5),那么我将花费时间来将它们全部放在一个故事板中。

#1


2  

Storyboard and nib files can be used in the same project without issue. You can instantiate a VC with nib name just as easily with a storyboard based VC as you can otherwise. The one piece of advice I would give you is if feasible, convert nibs over to storyboard just so the app is easier to manage later on. If you have a legacy app with several nibs, this might not be very time effective, but if you have only a small number (less than 5 I would say), I would make the time investment to have them all in a single storyboard.

故事板和nib文件可以在同一个项目中使用,没有问题。你可以用nib的名字来实例化一个VC,就像你可以用一个基于故事板的VC一样。我给你的一条建议是,如果可行的话,把nib转换到故事板,这样应用程序就会更容易管理。如果您有一个带有几个nib的遗留应用程序,这可能不是很有效的时间,但是如果您只有一个小的数字(小于5),那么我将花费时间来将它们全部放在一个故事板中。