最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【整理】Cocoa的nib文件

Cocoa crifan 3274浏览 0评论

nib文件就是:

你在Xcode中的Interface Builder中,在图形界面的方式下,编辑、设计出来的不同的页面视图,

内部存储成了对应的nib文件

-》nib文件保存和压缩了,你所编辑的图形界面的所有数据。

-》而代码中,想要调用,你已经设计,编辑,好了的图形界面视图的话,则是去使用:awakeFromNib

 

Xcode中的info.plist中,可以通过:

Main storyboard file base name

给程序添加nib文件:

xcode info plist add Main storyboard file base name

 

nib:文件夹,内含二进制文件

xib:xml文件

storyboard==多个xib文件==管理多个ViewController + 导航(页面跳转)关系

发展关系:

nib-》xib-》StoryBoard

 

参考资料

– awakeFromNib – NSNibAwaking Protocol Reference

 

Tips and Techniques for Framework Developers

A nib file is a special type of resource file that you use to store the user interfaces of iOS and Mac apps. A nib file is an Interface Builder document. You use Interface Builder to design the visual parts of your app—such as windows and views—and sometimes to configure nonvisual objects, such as the controller objects that your app uses to manage its windows and views. In effect, as you edit an Interface Builder document, you create an object graph that is then archived when you save the file. When you load the file, the object graph is unarchived.

The nib file—and hence the object graph—may contain placeholder objects that are used to refer to objects that live outside of the document but that may have references to objects in the document, or to which objects in the document may have references. A special placeholder is the File’s Owner.

At runtime, you load a nib file using the method loadNibNamed:owner: or a variant thereof. The File’s Owner is a placeholder in the nib file for the object that you pass as the owner parameter of that method. Whatever connections you establish to and from the File’s Owner in the nib file in Interface Builder are reestablished when you load the file at runtime.

iOS uses nibs as an implementation detail that supports storyboards, the iOS user interface design layout format. Storyboards allow you to design and visualize the entire user interface of your app on one canvas. For iOS developers, using storyboards is the recommended way to design user interfaces.

 

Nib Files

 

iOS之nib、xib及storyboard的区别 – LVXIANGAN的专栏 – 博客频道 – CSDN.NET

我们经常可以听到nib开发或xib开发之类的术语,但两者有什么区别呢?其实两者说的意思差不多。

nib是3.0版本以前的产物,在终端下我们可以看到,NIB其实是一个文件夹,里面有可执行的二进制文件;

xib是一个基于xml的描述文件,可以实现可视化编程。

无论nib也好,xib也好,最终在执行UIViewController生命周期函数loadView之前,都会转化成可执行的nib文件。

storyboard是多个xib文件集合的描述文件,也采用xml格式。

那么storyboard与xib比较,区别在于:

一个工程中可以有多个xib文件,一个xib文件对应着一个视图控制器和多个视图。而使用storyboard时,一个工程只需要一个主 storyboard文件就可以了。因此,在包含多个视图控制器的情况下,采用storyboard管理比较方便,而且storyboard还可以描述界面之间的导航关系。

 

Nib文件是什么?Nib文件打开方法_IOS_脚本之家

nib文件是Cocoa App的界面资源,代码中一般用xib代替了nib,因为这样方便版本管理。发布出去的仍然是nib,而且是编译后的nib,这种文件直接用xcode是不能被打开的。

 

ios开发中nib是个什么东西,有很多方法都有这个关键词,如:awakeFromNib,覆盖这个方法的目的是什么? – madao 的回答 – 知乎

我来自己回答好了:这是以前的叫法,现在叫xib。

 

iOS开发那些事–nib、xib与故事板的关系 – 开源中国社区

最初只有nib文件,后来将其更名为xib,但大家一直沿袭nib这个叫法(即称xib文件为nib文件),所以目前为止,nib等同于xib。xib文件采用xml格式。

前文已提到故事板是用来替代xib的

转载请注明:在路上 » 【整理】Cocoa的nib文件

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.194 seconds, using 22.07MB memory