NIB文件

作者: dzhou3 | 来源:发表于2017-08-08 07:30 被阅读0次

    Apple document says:

    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 methodloadNibNamed: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.

    构建项目时,所有的XIB文件都会被编译成NIB文件(NIB文件体积更小,更容易解析),然后Xcode将NIB文件拷贝到应用的程序包(bundle),程序包其实就是目录,其中包含应用可执行文件和其所用到的所有资源。

    应用在运行时刻会从程序包中按需载入NIB文件并激活文件中的对象。

    https://developer.apple.com/library/content/documentation/General/Conceptual/DevPedia-CocoaCore/NibFile.html#//apple_ref/doc/uid/TP40008195-CH34-SW1

    相关文章

      网友评论

          本文标题:NIB文件

          本文链接:https://www.haomeiwen.com/subject/xhwzlxtx.html