一个 xib 文件或多个 xib 文件
我制作了一个只有一个 xib 文件的选项卡栏应用程序。如果您之前制作过标签栏应用程序,那么您可能知道我做了什么,所以我实际上不必解释它。我删除了两个xib文件并使用MainWindow.xib。我刚刚向每个选项卡栏按钮添加了视图,并为每个按钮分配了视图控制器。
现在我有一个带有多个视图和按钮的选项卡栏应用程序,并且只有一个 xib 文件。为了节省内存,为每个视图都有一个单独的 xib 文件会更好吗?有什么区别吗?
另外,为什么标签栏模板这么奇怪?资源管理是否更好?在我看到的关于制作标签栏应用程序的每个教程中,人们都偏离了模板。
I made a tab bar application that has only one xib file. If you have have made tab bar applications before then you probably know what I did so I don't really have to explain it. I deleted the two xib files and used MainWindow.xib. I just added views to each tab bar button and assigned view controllers to each of them.
So now I have a tab bar application with multiple views and buttons and only one xib file. Would it be better to have a separate xib file for each view in order to conserve memory? Does it make any difference?
Also, why is the tab bar template so weird? Is it somehow better for resource management? In every tutorial I've seen about making tab bar apps people deviate from the template.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,对于资源管理来说,拥有多个 xib 会更好。当 xib 被加载时,它会立即加载其所有内容。例如,如果您有一个选项卡栏应用程序,则与选项卡关联的每个视图将同时位于内存中,这是低效的。
但是,如果您的应用程序足够简单,那并不重要,因此在这种情况下,请执行最简单的操作。
Yes it is better for resource management to have multiple xibs. When a xib gets loaded it loads all of its content at once. If you have a tab bar application for instance, each of the views associated with a tab will be in memory at the same time, which is inefficient.
However, if your application is simple enough it doesn't really matter, so do whatever is easiest in that case.