.xib文件和.storyboard之间的区别是什么?

时间:2022-03-10 03:43:38

Can someone explain in simple words the difference between .xib and .storyboard?

有人能用简单的语言解释。xib和。storyboard的区别吗?

6 个解决方案

#1


103  

Apple introduced the concept of "storyboarding" in iOS5 SDK to simplify and better manage screens in your app. You can still use the .xib way of development.

苹果在iOS5 SDK中引入了“故事板”的概念,以简化和更好地管理应用程序中的屏幕。

Pre-storyboard, each UIViewController had an associated .xib with it. Storyboard achieves two things:

在storyboard之前,每个UIViewController都有一个关联的。xib。故事板完成两件事:

  1. .storyboard is essentially one single file for all your screens in the app and it shows the flow of the screens. You can add segues/transitions between screens, this way. So, this minimizes the boilerplate code required to manage multiple screens.

    storyboard实质上是应用程序中所有屏幕的一个文件,它显示屏幕的流。您可以在屏幕之间添加segues/转换。因此,这将最小化管理多个屏幕所需的样板代码。

  2. Minimizes the overall number of files in an app.

    最小化应用程序中文件的总数。

You can avoid using Storyboard while creating a new project by leaving the "Use Storyboard" option unchecked.

在创建新项目时,可以不选中“使用故事板”选项,从而避免使用故事板。

You could refer this tutorial to get started.

您可以参考本教程开始学习。

#2


22  

Yes, you can still create a Window-based application for iOS 5. If you use the "empty project" template, you will see that a window is created for you in the app delegate. From there you can add XIB files as normal, or a new storyboard.

是的,您仍然可以为iOS 5创建一个基于windows的应用程序。如果您使用“空项目”模板,您将看到在应用程序委托中为您创建了一个窗口。从那里,您可以像往常一样添加XIB文件,或者添加一个新的故事板。

I'm assuming you mean "storyboards" rather than "timeline". Storyboards allow you to map out, visually, all of the views in your applications and how they interrelate. If you are just starting out with storyboards, there's an introduction to storyboards in the WWDC 2011 videos here. The 2011 Stanford iOS course on iTunes-U is also iOS 5-specific and covers storyboards and more.

我猜你指的是“故事板”而不是“时间线”。故事板允许您从视觉上描绘出应用程序中的所有视图以及它们之间的相互关系。如果你刚开始使用故事板,在2011年的WWDC上有一个故事板介绍。2011年斯坦福大学iOS课程的iTunes-U也是针对iOS 5的,涵盖了故事板等内容。

#3


12  

A storyboard is like a canvas where you put all your .xib files. You no longer have any .xibs, you just have View Controllers directly on your canvas.

故事板就像一个画布,你可以将所有的。xib文件放在其中。您不再拥有任何.xib,您只需在画布上直接拥有视图控制器。

#4


8  

storyboard is a new feature available since the release of Xcode 4.2. It offers a complete new way for iOS developer to create and design user interface. Before the introduction of Storyboard, it’s especially hard for beginner to create navigation (and tab) interface. Every interface is stored in a separate xib file. On top of it, you have to write code to link all interfaces together and describe how the navigation works.

故事板是自Xcode 4.2发布以来的一个新特性。它为iOS开发人员提供了一种全新的创建和设计用户界面的方式。在引入故事板之前,初学者很难创建导航(和选项卡)界面。每个接口都存储在一个单独的xib文件中。最重要的是,您必须编写代码将所有接口连接在一起,并描述导航是如何工作的。

With Storyboards, all screens are stored in a single file. This gives you a conceptual overview of the visual representation for the app and shows you how the screens are connected. Xcode provides a built-in editor to layout the Storyboards. You can define the transition (known as segues) between various screens simply using point and click. This doesn’t mean you do not need to write code for the user interface. But Storyboards significantly reduce the amount of code you need to write.

使用故事板,所有的屏幕都存储在一个文件中。这将使您对应用程序的可视化表示有一个概念性的概述,并向您展示屏幕是如何连接的。Xcode提供了一个内置的编辑器来布局故事板。您可以在不同的屏幕之间定义转换(称为segues),只需使用point并单击即可。这并不意味着您不需要为用户界面编写代码。但是故事板大大减少了您需要编写的代码量。

Source: http://www.appcoda.com/use-storyboards-to-build-navigation-controller-and-table-view/

来源:http://www.appcoda.com/use-storyboards-to-build-navigation-controller-and-table-view/

#5


1  

XIB:

XIB:

1) Xib files are used with a single UIView.

1) Xib文件用于一个UIView。

2)It's very difficult to implement complex auto-layouts in xib.

2)在xib中实现复杂的自动布局非常困难。

3)It's utilizes more memory as compared to storyboard and quiet slow.

3)与故事板相比,它使用了更多的内存,而且速度很慢。

4) It is compatible from iOS5 and onwards

4)从iOS5开始兼容

5) You can do localizations for different languages and countries using different XIBs .

5)您可以使用不同的xib对不同的语言和国家进行本地化。

6) It's difficult to use same Xib to support multiple devices.

6)使用相同的Xib来支持多个设备是很困难的。

Storyboard

故事板

1)You can layout all your Scenes like View Controllers, Nav Controllers, TabBar Controllers, etc in a single storyboard.

1)你可以在一个故事板中布局你的所有场景,比如视图控制器,导航控制器,TabBar控制器等等。

2)You can use Auto Layout easily that defines mathematical relationships between elements defining their position and sizing.

2)你可以很容易地使用自动布局来定义定义其位置和大小的元素之间的数学关系。

3)Usually fast and allocates less memory.

3)通常快速,分配较少的内存。

4)It's not compatible prior to iOS 5 .

4) ios5之前不兼容。

5)"Dynamic" and "Prototype" cells can be used easily.

5)“动态”和“原型”单元可以很容易地使用。

6)Storyboards best to use for the apps with a small to medium amount of screens.

6)故事板最适合用于小到中等屏幕的应用程序。

The best Answer I have seen : Xib Vs Storyboard in iOS

我看到的最好的答案是:Xib Vs iOS中的故事板

#6


0  

XIB and Storyboard are used for creating interfaces for users.

XIB和Storyboard用于为用户创建接口。

One important point is,xibs are used for creating a single view(it has single file owner at the top of the xib file), but in-case for viewcontroller, multiple screens can be added and its flow can also be monitored(it has separate file owners).

重要的一点是,xibs用于创建一个视图(它在xib文件的顶部有一个文件所有者),但是对于viewcontroller,可以添加多个屏幕,并且可以监视它的流(它有独立的文件所有者)。

#1


103  

Apple introduced the concept of "storyboarding" in iOS5 SDK to simplify and better manage screens in your app. You can still use the .xib way of development.

苹果在iOS5 SDK中引入了“故事板”的概念,以简化和更好地管理应用程序中的屏幕。

Pre-storyboard, each UIViewController had an associated .xib with it. Storyboard achieves two things:

在storyboard之前,每个UIViewController都有一个关联的。xib。故事板完成两件事:

  1. .storyboard is essentially one single file for all your screens in the app and it shows the flow of the screens. You can add segues/transitions between screens, this way. So, this minimizes the boilerplate code required to manage multiple screens.

    storyboard实质上是应用程序中所有屏幕的一个文件,它显示屏幕的流。您可以在屏幕之间添加segues/转换。因此,这将最小化管理多个屏幕所需的样板代码。

  2. Minimizes the overall number of files in an app.

    最小化应用程序中文件的总数。

You can avoid using Storyboard while creating a new project by leaving the "Use Storyboard" option unchecked.

在创建新项目时,可以不选中“使用故事板”选项,从而避免使用故事板。

You could refer this tutorial to get started.

您可以参考本教程开始学习。

#2


22  

Yes, you can still create a Window-based application for iOS 5. If you use the "empty project" template, you will see that a window is created for you in the app delegate. From there you can add XIB files as normal, or a new storyboard.

是的,您仍然可以为iOS 5创建一个基于windows的应用程序。如果您使用“空项目”模板,您将看到在应用程序委托中为您创建了一个窗口。从那里,您可以像往常一样添加XIB文件,或者添加一个新的故事板。

I'm assuming you mean "storyboards" rather than "timeline". Storyboards allow you to map out, visually, all of the views in your applications and how they interrelate. If you are just starting out with storyboards, there's an introduction to storyboards in the WWDC 2011 videos here. The 2011 Stanford iOS course on iTunes-U is also iOS 5-specific and covers storyboards and more.

我猜你指的是“故事板”而不是“时间线”。故事板允许您从视觉上描绘出应用程序中的所有视图以及它们之间的相互关系。如果你刚开始使用故事板,在2011年的WWDC上有一个故事板介绍。2011年斯坦福大学iOS课程的iTunes-U也是针对iOS 5的,涵盖了故事板等内容。

#3


12  

A storyboard is like a canvas where you put all your .xib files. You no longer have any .xibs, you just have View Controllers directly on your canvas.

故事板就像一个画布,你可以将所有的。xib文件放在其中。您不再拥有任何.xib,您只需在画布上直接拥有视图控制器。

#4


8  

storyboard is a new feature available since the release of Xcode 4.2. It offers a complete new way for iOS developer to create and design user interface. Before the introduction of Storyboard, it’s especially hard for beginner to create navigation (and tab) interface. Every interface is stored in a separate xib file. On top of it, you have to write code to link all interfaces together and describe how the navigation works.

故事板是自Xcode 4.2发布以来的一个新特性。它为iOS开发人员提供了一种全新的创建和设计用户界面的方式。在引入故事板之前,初学者很难创建导航(和选项卡)界面。每个接口都存储在一个单独的xib文件中。最重要的是,您必须编写代码将所有接口连接在一起,并描述导航是如何工作的。

With Storyboards, all screens are stored in a single file. This gives you a conceptual overview of the visual representation for the app and shows you how the screens are connected. Xcode provides a built-in editor to layout the Storyboards. You can define the transition (known as segues) between various screens simply using point and click. This doesn’t mean you do not need to write code for the user interface. But Storyboards significantly reduce the amount of code you need to write.

使用故事板,所有的屏幕都存储在一个文件中。这将使您对应用程序的可视化表示有一个概念性的概述,并向您展示屏幕是如何连接的。Xcode提供了一个内置的编辑器来布局故事板。您可以在不同的屏幕之间定义转换(称为segues),只需使用point并单击即可。这并不意味着您不需要为用户界面编写代码。但是故事板大大减少了您需要编写的代码量。

Source: http://www.appcoda.com/use-storyboards-to-build-navigation-controller-and-table-view/

来源:http://www.appcoda.com/use-storyboards-to-build-navigation-controller-and-table-view/

#5


1  

XIB:

XIB:

1) Xib files are used with a single UIView.

1) Xib文件用于一个UIView。

2)It's very difficult to implement complex auto-layouts in xib.

2)在xib中实现复杂的自动布局非常困难。

3)It's utilizes more memory as compared to storyboard and quiet slow.

3)与故事板相比,它使用了更多的内存,而且速度很慢。

4) It is compatible from iOS5 and onwards

4)从iOS5开始兼容

5) You can do localizations for different languages and countries using different XIBs .

5)您可以使用不同的xib对不同的语言和国家进行本地化。

6) It's difficult to use same Xib to support multiple devices.

6)使用相同的Xib来支持多个设备是很困难的。

Storyboard

故事板

1)You can layout all your Scenes like View Controllers, Nav Controllers, TabBar Controllers, etc in a single storyboard.

1)你可以在一个故事板中布局你的所有场景,比如视图控制器,导航控制器,TabBar控制器等等。

2)You can use Auto Layout easily that defines mathematical relationships between elements defining their position and sizing.

2)你可以很容易地使用自动布局来定义定义其位置和大小的元素之间的数学关系。

3)Usually fast and allocates less memory.

3)通常快速,分配较少的内存。

4)It's not compatible prior to iOS 5 .

4) ios5之前不兼容。

5)"Dynamic" and "Prototype" cells can be used easily.

5)“动态”和“原型”单元可以很容易地使用。

6)Storyboards best to use for the apps with a small to medium amount of screens.

6)故事板最适合用于小到中等屏幕的应用程序。

The best Answer I have seen : Xib Vs Storyboard in iOS

我看到的最好的答案是:Xib Vs iOS中的故事板

#6


0  

XIB and Storyboard are used for creating interfaces for users.

XIB和Storyboard用于为用户创建接口。

One important point is,xibs are used for creating a single view(it has single file owner at the top of the xib file), but in-case for viewcontroller, multiple screens can be added and its flow can also be monitored(it has separate file owners).

重要的一点是,xibs用于创建一个视图(它在xib文件的顶部有一个文件所有者),但是对于viewcontroller,可以添加多个屏幕,并且可以监视它的流(它有独立的文件所有者)。