Iphone sdk - 如何设置“模板”
我一直在开发一个烹饪书应用程序,我一直在单独制作每个页面,这需要很长时间才能完成,我问了一个与此类似的问题,这引起了我的注意,您可以设置一种自动化的方法设计过程中,您所需要做的就是输入数据。
有人可以尽可能详细地解释一下如何设置 xcode 文件/代码来自动执行这样的过程
例如我只需输入页面文本,它会自动将我的标准背景图片放入并添加滚动视图和适当的按钮等 谢谢
I've been working on a Cook Book App and I've been making each page individually which takes a really long time to do, I asked a question similar to this and it was brought to my attention that you can setup a way to automate the design process so all you need to do is input your data.
Can someone please explain in as much detail as possible how you setup your xcode files/code to automate such a process
So for example I would just enter the page text and it would automatically put my standard background picture in and add a scroll view and appropriate buttons etc.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以制作一个主视图,其中包含您需要的所有控件:标准背景图片、滚动视图、适当的按钮等,并使您创建的任何后续视图继承自该视图,以便它们都包含这些控件。
您还可以仅使用一个视图并使用它的多个实例,每页一个实例。只需确保其上有一个 Text 属性,或者有一个接受文本字符串的构造函数,以便您可以将其设置为每个页面上的不同文本。
You could make one master view that contains all the controls that you need: standard background picture, scroll view, appropriate buttons, etc, and make any subsequent views that you create inherit from this view, so that they all contain those controls.
You could also use just one view and work with multiple instances of it, one instance per page. Just make sure to have a Text property on it, or a constructor that takes in your text string, so that you could set it to a different text on each page.
Xcode 项目模板和文件模板非常容易制作,但有一些注意事项。
检查这些问题的答案:
在 Xcode 中添加新模板
更改 XCode 中的模板
另请参阅这些方便的教程:
自定义 Xcode 模板
Xcode:如何自定义现有项目模板
Xcode project templates and file templates are pretty easy to make, with a few caveats.
Check the answers to these questions:
Add new templates in Xcode
Change templates in XCode
Also take a gander at these handy tutorials:
Custom Xcode Templates
Xcode: How to customize the existing project templates
在我看来,这就像您将数据放入视图(页面)中。这是一个很大的设计错误。您需要采用模型-视图-控制器设计模式并将数据与视图分开。这将使创建一个视图(模板)变得容易,您可以重新加载数据以显示每个单独的食谱。
要做的第一件事是将数据与视图分离。您需要将食谱存储在数组、字典、核心数据等中,然后将该数据包装在专用对象中。要做的第二件事是创建一个专用视图来显示所有食谱。当用户从一个菜谱移动到另一个菜谱时,应用程序将根据需要简单地删除信息并将信息添加到同一视图中。
我会推荐Mac OS X 的可可食谱:佛蒙特州食谱,第二版,因为它解决了这些问题并且它使用食谱类型应用程序作为示例。它适用于 Cocoa,但基本原则也适用于 iPhone 应用程序。
It sounds to me like your putting your data into your views (pages). That's a big design error. You need to employ the Model-View-Controller design pattern and separate your data from your views. That will make it easy to create one view (template) that you can reload with data to display each individual recipe.
The first thing to do is to separate your data from the view. You need to have the recipes stored in an array, dictionary, Core Data etc and then wrap that data in a dedicated object. The second thing to do is to create a dedicated view to display all the recipes. As the user moves from recipe to recipe the app will simply remove and add information to the same view as needed.
I would recommend Cocoa Recipes for Mac OS X: The Vermont Recipes, Second Edition because it addresses these issues and it uses a recipe type app as its example. It's for Cocoa but the basic principles apply to iPhone apps as well.