Skip to Main Content
iOS 编程基础:Swift、Xcode 和Cocoa 入门指南
book

iOS 编程基础:Swift、Xcode 和Cocoa 入门指南

by Matt Neuburg
January 2017
Intermediate to advanced content levelIntermediate to advanced
552 pages
9h 43m
Chinese
China Machine Press
Content preview from iOS 编程基础:Swift、Xcode 和Cocoa 入门指南
项目的生命周期
399
如果修改
nib
会出现什么结果呢?假设在
Main.storyboard
中向视图再添加一个按钮。这
时与
nib
对应的
.strings
文件不会发生任何变化;我们需要手工重新生成这些文件(这也
是在实际情况下,为何要在界面开发工作基本完成时才开始本地化
nib
文件的原因所在)。
不过内容并未丢失:
1.
选中
Main.storyboard
,然后选择
File
Show in Finder
2.
运行
Terminal
。输入命令
xcrun ibtool --export-strings-file output.strings
后跟一个空格,然后将
Main.storyboard
Finder
拖曳到
Terminal
窗口,按回车键。
结果就是基于
Main.storyboard
的,名为
output.strings
的新文件会在主目录(也就是当
前目录)下生成。可以根据
Main.storyboard
将这部分信息与现有的本地化
.strings
文件
合并到一起。
在该示例中,我让你提前增加
"Hello"
钮的宽度,从而为更长的本地化文
"Bonjour"
留出足够的空间。在实际情况下,你可能会使用自动布局;这样按钮与标签
就会自动伸缩了,同时界面的其他部分会相应地进行补偿。
要在不同本地化的情况下测试界面,还可以在
Xcode
中预览本地化
nib
文件,而无须运
行应用。编辑
.storyboard
.xib
文件,打开辅助窗格,将追踪菜单切换至
Preview
。右
下角的菜单会列出本地化信息;可以在菜单中进行切换 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)

机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)

Aurélien Géron
Swift 人工智能实战:从基础理论到AI 驱动的应用程序开发

Swift 人工智能实战:从基础理论到AI 驱动的应用程序开发

Mars Geldard, Jonathon Manning, Paris Buttfield-Addison, Tim Nugent

Publisher Resources

ISBN: 9787111556350