如何在运行时编辑和保存 nib 文件?
想象一个应用程序有许多向用户显示的按钮。该应用程序希望允许用户在屏幕上移动按钮,自定义显示,然后保存此配置以供以后使用。也就是说,当应用程序关闭并重新启动时,它将以相同的配置恢复。
我想创建一个具有“出厂默认”按钮布局的 nib 文件,然后在用户按照他们喜欢的方式配置它后创建一个新的 nib 文件来存储新的 UI。如何做到这一点?
谢谢!
Imagine an application that has a number of buttons it is displaying to the user. This application wants to allow the user to move the buttons around on the screen, customizing the display, and then save this configuration for later use. That is, when the app is closed and relaunched, it will come back up with the same configuration.
I would like to create a nib file with the "factory default" button layout, but then create a new nib file storing the new UI after the user has configured it just the way they like it. How does one do this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看
这将做你想要的。包含所有子视图、属性等。
Have a look at
This will do what you want. With all subviews, properties etc.
你真的没有创建一个新的笔尖。
其一,您不能期望用户安装开发工具。所以你需要以编程方式实现这些动态部分。
也许导出一个包含可变属性的颜色、位置等的字典;然后将这些属性应用于这些对象(因此它很像 nib 的 xml 表示上的一个简单层)。
如果您当前没有使用标签来识别笔尖的对象,这可能是识别导出的字典中的对象的简单方法。
祝你好运
you really don't create a new nib.
for one, you can't expect the user to have the devtools installed. so you need to implement these dynamic parts programmatically.
perhaps export a dictionary with colors, positions, etc. for the mutable properties; then apply those properties to those objects (so it's quite like a simple layer over a nib's xml representation).
if you are not currently using tags to identify your nib's objects, that may be an easy way to identify objects in your exported dictionary.
good luck