简体   繁体   English

在Objective-C中加载/卸载新视图

[英]Load/unload new views in Objective-C

I am currently testing this environment and would like to ask about the best strategy loading/unloading for a multiview application. 我目前正在测试此环境,并想询问有关多视图应用程序的最佳策略加载/卸载。

The app i am playing around with should have the following: 我正在玩的应用程序应具有以下内容:

Main: a normal view with 5 x buttons (Play, Leaderboard, Properties, Instructions and an "i" button for about) Main:具有5个按钮的普通视图(播放,排行榜,属性,说明和一个“ i”按钮,用于大约)

The Properties is a tableView where each cell opens up a new tableView with the actual properties. 属性是一个tableView,其中每个单元格都会打开一个具有实际属性的新tableView。

What is the best strategy from a flexibility and memory point of view to do this? 从灵活性和内存的角度来看,这样做的最佳策略是什么?

Store the extra views in their own nib-files. 将额外的视图存储在自己的nib文件中。 Load them in when needed using +[NSBundle loadNibNamed:@"nibFileName" owner:self] . 在需要时使用+[NSBundle loadNibNamed:@"nibFileName" owner:self]加载它们。 Replace self with whatever object that you want the nib's "File's Owner" to point to. self替换为您希望笔尖的“文件所有者”指向的任何对象。 (Usually it would be self , though, since it would be the view's controller whose job it was to create the nib; and the controller is also typically what you want as your File's Owner.) (不过,通常它将是self ,因为它将是创建笔尖的视图控制器 ,并且该控制器通常也是您作为文件所有者所需要的。)

Disclaimer : I'm basing this on my knowledge of Cocoa on the desktop, but I'm pretty sure nib-files work the same on the iPhone. 免责声明 :我是基于我在台式机上对可可的了解,但是我很确定笔尖文件在iPhone上可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM