App Design Basics

App Design Basics
应用程序设计基础
 
If you are a new to developing iOS apps, you might be wondering where the app development process starts. After devising your initial idea for an app, you need to turn that idea into an action plan for implementing your app. From a design perspective, you need to make some high-level decisions about the best course of action for implementing your ideas. You also need to set up your initial Xcode project in a way that makes it easy to proceed with development.
如果你是iOS apps的开发新手,你可能想要知道,app的开发流程应当从哪里开始。在设计你的第一个app的最初想法之后,你需要把想法变成一个可执行计划。从一个设计的角度上,你需要做一些高层次的决定,关于实现你的想法的最好的动作过程。你也需要设置你的最初的Xcode工程,让它更适合开发。


If you are new to developing iOS apps altogether, spend some time familiarizing yourself with the basic concepts. There are tutorials to help you jump right in if you want to start writing code, but iOS is a system built from basic design patterns. Taking a little bit of time to learn those patterns will help you tremendously later.
如果你对开发iOS apps完全的新手,花费一些时间熟悉一些基本概念。这里有教程帮助你进入,如果你想要开始编码,但是iOS是一个建立于基本设计模式的系统。花点时间来学习这些设计模式稍后会对你有巨大的帮助。


Doing Your Initial Design
做你最初的设计


There are many ways to design an app, and many of the best approaches do not involve writing any code. A great app starts with a great idea that you then expand into a more full-featured product description. Early in the design phase, it helps to understand just what you want your app to do. Write down the set of high-level features that would be required to implement your idea. Prioritize those features based on what you think your users will need. Do a little research into iOS itself so that you understand its capabilities and how you might be able to use them to achieve your goals. And sketch out some rough interface designs on paper to visualize how your app might look.
有许多方法来设计一个app,也有许多最好的方法不会写任何代码。一个好的app开始于一个好的想法,然后扩展到一个更全面的产品特性描述。设计阶段的早期,他帮助你理解,你的app想要做什么。写下一些实现你的想法所要求的高层的特性。优先是这些特性是基于你认为你当用户可能会需要。在iOS里做一些小调查,因此你能够理解它的能力,和你如何能够使用它们来达到你的目标。然后在一张纸上勾勒出一些大体的界面设计,来展示你的app可能看起来是个什么样子的。


The goal of your initial design is to answer some very important questions about your app. The set of features and the rough design of your interface help you think about what will be required later when you start writing code. At some point, you need to translate the information displayed by your app into a set of data objects. Similarly, the look of your app has an overwhelming influence on the choices you must make when implementing your user interface code. Doing your initial design on paper (as opposed to on the computer) gives you the freedom to come up with answers that are not limited by what is easy to do.
你最初设计的目标是回答一些非常重要的问题,关于你的app。特性集合和原型设计帮助你思考关于稍后什么将会被需要,当你开始写代码的时候。同样,你需要将你的app显示出来的信息翻译成一些数据对象的集合。同样的,当你实现你的用户界面的代码时,你的app的样子对你做选择有很大的影响。把你最初的设计画到纸上(而不是电脑上),给你自由来回答,这不限于什么是很容易做到的。


Of course, the most important thing you can do before starting your initial design is read iOS Human Interface Guidelines. That book describes several strategies for doing your initial design. It also offers tips and guidance about how to create apps that work well in iOS. You might also read iOS Technology Overview to understand how the capabilities of iOS and how you might use those capabilities to achieve your design goals.
当然,在你开始你的最初设计之前你能做的最重要的事情就是阅读iOS Human Interface Guidelines。这本书描述了一些策略,关于做最初设计。他也提供了一些提示和指南关于如何创建在iOS上工作良好的app。你可能需要阅读iOS Technology Overview来理解iOS的能力和你如何使用这些能力来达到你的设计目标。


Learning the Fundamental iOS Design Patterns and Techniques
学习iOS设计模式的基础和技术


No matter what type of app you are creating, there are a few fundamental design patterns and techniques that you must know before you start writing code. In iOS, the system frameworks provide critical infrastructure for your app and in most cases are the only way to access the underlying hardware. In turn, the frameworks use many specific design patterns and assume that you are familiar with them. Understanding these design patterns is therefore an important first step to understanding how the system can help you develop your app.
不管你要创建什么类型的app,这里有一些基础的设计模式和技术,你在开始写代码之前必须要知道的。在iOS中,系统框架为你的应用程序提供了严格的基础设施,并且在大多数情况下,只有一个方法来访问底层的硬件。反过来,框架使用了许多具体的设计模式并且假设你熟悉了他们。理解这些设计模式是理解系统如何帮助你开发你的app的重要的第一步。


The most important design patterns you must know are:
你必须知道的最重要的设计模式有:


Model-View-Controller—This design pattern governs the overall structure of your app.
MVC模式,这个模式控制了app的所有结构。
Delegation—This design pattern facilitates the transfer information and data from one object to another.
委托模式,这个模式有利于交换信息和数据从一个对象到另一个对象的传输。
Target-action—This design pattern translates user interactions with buttons and controls into code that your app can execute.
目标-行为模式,这个设计模式翻译用户通过按钮的交互并且控制app可以执行的代码。
Block objects—You use blocks to implement callbacks and asynchronous code.
块对象模式,你使用块来实现回调和异步代码。
Sandboxing—All iOS apps are placed in sandboxes to protect the system and other apps. The structure of the sandbox affects the placement of your app’s files and has implications for data backups and some app-related features.
沙盒,所有的iOS apps都放在沙盒中来保护系统和其他apps.沙盒的结构影响你的app的文件的位置,以及影响数据备份和一些app相关的特性。
Accurate and efficient memory management is important for iOS apps. Because iOS apps typically have less usable memory than a comparable desktop computer, apps need to be aggressive about deleting unneeded objects and be lazy about creating objects in the first place. Apps that use the compiler’s Automatic Reference Counting (ARC) feature already get a very efficient way of managing memory that is similar to garbage collection but without many of the performance penalties. If you are not using ARC, you must manage memory yourself by explicitly retaining and releasing objects.
精确和高效的内存管理对iOS apps来讲是很重要的。因为iOS apps与普通的兼容型桌面计算机相比通常只有很少可以使用的内存,apps需要具有侵略性,删除不需要的对象,并且在第一处创建对象的方面很懒。apps使用编译器的原子引用计数(ARC)特性,获取管理内存非常有效的方法,类似于垃圾回收但是不影响性能。如果你不使用ARC,你必须自己管理内存,明确的保留和释放对象。


There are other design patterns that you might see used occasionally or use yourself in your own code. For a complete overview of the design patterns and techniques you will use to create iOS apps, see Cocoa Fundamentals Guide.
也有其他的设计模式你可能会偶尔的使用到,或者在你自己的代码中使用。对于创建iOS app所用到的设计模式和技术的完整的概览,参考Cocoa Fundamentals Guide.


Translating Your Initial Design into an Action Plan
将你的设计翻译成为行动计划


iOS assumes that all apps are built using the Model-View-Controller design pattern. Therefore, the first step you can take toward achieving this goal is to choose an approach for the data and view portions of your app.
iOS假设所有的apps都使用了MVC的设计模式。因此你实现这个目标的第一步是为你的app的数据和视图部分选择一个方法。


Choose a basic approach for your data model:
为你的数据模型选择一个基本方法:
Existing data model code—If you already have data model code written in a C-based language, you can integrate that code directly into your iOS apps. Because iOS apps are written in Objective-C, they work just fine with code written in other C-based languages. Of course, there is also benefit to writing an Objective-C wrapper for any non Objective-C code.
已存在的数据模型代码————如果你已经有了用C写的数据模型代码,你可以把这些代码直接继承到你的iOS apps中。因为iOS app是用Objectiv-C写成的,他们与其他的基于C写成的程序可以良好的工作在一起。当然,对于任何非Objectiv-C写的代码用Objective-C进行包裹是有益处的。
Custom objects data model—A custom object typically combines some simple data (strings, numbers, dates, URLs, and so on) with the business logic needed to manage that data and ensure its consistency. Custom objects can store a combination of scalar values and pointers to other objects. For example, the Foundation framework defines classes for many simple data types and for storing collections of other objects. These classes make it much easier to define your own custom objects.
地址对象数据模式————一个定制对象通常有一些简单的数据组成(Strings, numbers, dates, URLs等),有一些业务逻辑需要被管理,并且确保其一致性。举例,框架基础为许多简单的数据类型和用于存储其他对象的集合定义了类。这些类使得定义你自己的定制类型变的简单。
Structured data model—If your data is highly structured—that is, it lends itself to storage in a database—use Core Data (or SQLite) to store the data. Core Data provides a simple object-oriented model for managing your structured data. It also provides built-in support for some advanced features like undo and iCloud. (SQLite files cannot be used in conjunction with iCloud.)
结构化数据模型————如果你的数据是高度结构化的,它本身存储在一个数据里——使用Core Date(或者SQLite)来存储数据。Core Data提供了一个简单的面向对象模型来管理你的结构化数据。它也为一些高级特性比如undo和iCloud提供了内建的支持。(SQLite文件不能用于与iCloud进行连接)
Decide whether you need support for documents:
决定是否你需要支持文件:
The job of a document is to manage your app’s in-memory data model objects and coordinate the storage of that data in a corresponding file (or set of files) on disk. Documents normally connote files that the user created but apps can use documents to manage non user facing files too. One big advantage of using documents is that the UIDocument class makes interacting with iCloud and the local file system much simpler. For apps that use Core Data to store their content, the UIManagedDocument class provides similar support.
文件的工作是来管理你的app的在内存中的数据模型对象和协调数据在硬盘上相关文件的存储。文件通常意味着用户创建的文件但是apps也可以使用文件来管理费用户面对的文件。使用文档的一个大的优势是UIDocument类使得与iCloud和本地文件系统的交互更加简单。对于使用Core Data存储他们的内容的app,UIManagedDocument类提供了简单的支持。


Choosing an approach for your user interface:
为你的用户界面选择一个方法:
Building block approach—The easiest way to create your user interface is to assemble it using existing view objects. Views represent visual elements such as tables, buttons, text fields, and so on. You use many views as-is but you can also customize the appearance and behavior of standard views as needed to meet your needs. You can also implement new visual elements using custom views and mix those views freely with the standard views in your interface. The advantages of views are that they provide a consistent user experience and they allow you to define complex interfaces quickly and with relatively little code.
建立块方法————创建用户界面最简单的方法是使用已经存在的视图对象来组装。视图表现了虚拟元素比如tables,butons,text fields等等。你使用许多视图as-is但是你也可以定制一个标准views的外观和行为,为了符合你的需求。你也可以使用定制views来实现新的可视化元素,然后在你的界面中自由的组合这些元素。views的优势是他们提供了一致的体验并且他们允许你用相当少的代码快速的定义复杂的界面。
OpenGL ES-based approach—If your app requires frequent screen updates or sophisticated rendering, you probably need to draw that content directly using OpenGL ES. The main use of OpenGL ES is for games and apps that rely heavily on sophisticated graphics, and therefore need the best performance possible.
基于OpenGL ES的方法————如果你的应用程序要求经常更新屏幕或者复杂的渲染,你可能需要使用OpenGL ES直接画内容。OpengGL ES的主要使用是对于游戏和依赖于复杂渲染的app,因此需要可能的最好的性能。


Starting the App Creation Process
开始应用程序建立步骤


After you formulate your action plan, it is time to start coding. If you are new to writing iOS apps, it is good to take some time to explore the initial Xcode templates that are provided for development. These templates greatly simplify the work you have to do and make it possible to have an app up and running in minutes. These templates also allow you to customize your initial project to support your specific needs more precisely. To that end, when creating your Xcode project, you should already have answers to the following questions in mind:
在你创建了你的行动计划之后,现在是开始编码的时候了。如果你是写iOS app的新手,最好花时间研究下提供给开发的最初的Xcode模板。这些模板很好的简化了你需要做的工作,并且让代码形成一个app,能够在很短的时间内运行起来。这些模板也允许你定制你自己的项目来支持你的具体的需求。最后,当创建你的Xcode项目的时候,你应该已经在头脑中回答了下面的问题:


What is the basic interface-style of your app? Different types of app require different sets of initial views and view controllers. Knowing how you plan to organize your user interface lets you select an initial project template that is most suited to your needs. You can always change your user interface later, but choosing the most appropriate template first makes starting your project much easier.
你的app的基本的界面样式是什么?不同的样式需要不同的初始化视图和视图控制。知道你的计划如何形成用户界面会让你选择一个更适合你的需求的初始化项目模板。你可以在稍后改变你的用户界面,但是选择更合适的模板会让你的项目开始的时候更简单点。
Do you want to create a Universal app or one targeted specifically for iPad or iPhone? Creating a universal app requires specifying different sets of views and view controllers for iPad and iPhone and dynamically selecting the appropriate set at runtime. Universal apps are preferred because they support more iOS devices but do require you to factor your code better for each platform. For information about how a universal app affects the code you write, see “Creating a Universal App.”
你想创建一个普通的app还是一个有目标的具体的为了iPad或是iPhone的?创建一个普通的app需要具体的不同的视图集合和视图控制,与iPad和iPhone不同,并且在运行时动态的选择适当的设置。普通的程序更好,因为他们支持更多的iOS设备,但是需要你为不同的平台改动代码。关于普通的程序如何影响你写的代码,参考"Creating a Universal App"
Do you want your app to use storyboards? Storyboards simplify the design process by showing both the views and view controllers of your user interface and the transitions between them. Storybards are supported in iOS 5 and later and are enabled by default for new projects. If your app must run on earlier versions of iOS, though, you cannot use storyboards and should continue to use nib files.
你的app想要使用storyboard么?storeboard通过显示用户界面的视图和视图控制和他们之间的传输来简化了设计过程。storyboard在iOS 5中支持,对于新的项目默认开启。如果你的app必须运行在早版本的iOS上,虽然,你不能使用storyboard,应该继续使用nib文件。
Do you want to use Core Data for your data model? Some types of apps lend themselves naturally to a structured data model, which makes them ideal candidates for using Core Data. For more information about Core Data and the advantages it offers, see Core Data Programming Guide.
你想为你的data model使用Core Data么?一些app的样式使他们自己自然的为结构化数据模型,
使得它们为使用Core Data称为了想法的候选。关于Core Data的更多信息和它们的优势,参考"Core Data Programming Guilde."


From these questions, you can use Xcode to create your initial project files and start coding.
解决了这些问题,你可以使用Xcode来创建你的工程文件然后开始编码。


1 If you have not yet installed Xcode, do so and configure your iOS development team. For detailed information about setting up your development teams and and preparing your Xcode environment, see App Development Overview.
1 如果你还没有安装Xcode,安装它,并且配置你的iOS开发组。 对于设置开发组和准备Xcode环境的详细信息参考"App Development Overview."


2 Create your initial Xcode project.
2 创建你的Xcode工程。


3 Before writing any code, build and run your new Xcode project. Target your app for iOS Simulator so that you can see it run.
3 在你写代码前,编译并运行你的新Xcode项目,选择你的app为iOS仿真,这样你就能看到它运行了。
Every new Xcode project starts you with a fully functional (albeit featureless) app. The app itself should run and display the default views found in the main storyboard or nib file, which are probably not very interesting. The reason that the app runs at all, though, is because of the infrastructure provided to you by UIKit. This infrastructure initializes the app, loads the initial interface file, and checks the app in with the system so that it can start handling events. For more information about this infrastructure and the capabilities it provides, see “The Core Objects of Your App” and “The App Launch Cycle.”
每一个新的Xcode工程都使用一个全功能的app开始。app自己应该运行和显示在main storyboard或者nib file中的默认的views,可能不会很有意思。原因是app运行了,因为是UIKit为你提供了基础设施。基础设施初始化了app,装载了初始化界面文件,检查了app所在的系统,因此它可以开始处理事件。对于基础设施和它所能提供能力的更多细节,参考"The Core Objects of Your App"和"The App Launch Cycle."


4 Start writing your app’s primary code.
4 开始写你的app的主要代码。
For new apps, you probably want to start creating the classes associated with your app’s data model first. These classes usually have no dependencies on other parts of your app and should be something you can work on initially. For information about ways to build your data model, see “The Data Model.”
对于新的apps,你可能想要开始创建数据模型相关的类。这些类通常不依赖于app的其他部分并且可以初始化。关于建立数据模型,参考”The Data Model.“


You might also want to start playing around with designs for your user interface by adding views to your main storyboard or nib file. From these views, you can also start identifying the places in your code where you need to respond to interface-related changes. For an overview of user interfaces and where they fit into your app’s code, see “The User Interface.”
你可能想要在main storyboard或者nib file上设计你的用户界面。对于这些views你也可以开始在你需要响应界面相关改变的代码的位置。关于用户界面概览和在哪里融入你的代码中,参考"The User Interface."


If your app supports iCloud, you should incorporate support for iCloud into your classes at an early stage. For information about adding iCloud support to your app, see “iCloud Storage.”
如果你的app支持iCloud,你应该合并对iCloud的支持到你的类中,在早期阶段。关于添加iCloud支持到app中参考"iCloud Storage."


5 Add support for app state changes.
In iOS, the state of an app determines what it is allowed to do and when. App states are managed by high-level objects in your app but can affect many other objects as well. Therefore, you need to consider how the current app state affects your data model and view code and update that code appropriately. For information about app states and how apps run in the foreground and background, see “App States and Multitasking”
5 为app状态改变添加支持
在iOS中,一个app的状态决定了它被允许和何时做事情。app的状态由app中高层的对象管理,但是也能影响许多其他的对象。因此,你需要考虑当前的app状态如何影响数据模型和视图代码以及适当的更新代码。关于app状态和app如何在前台和后台运行,参考"App States and Multitasking"


6 Create the resources needed to support your app.
6 创建支持你的app需要的资源
Apps submitted to the App Store are expected to have specific resources such as icons and launch images to make the overall user experience better. Well-factored apps also make heavy use of resource files to keep their code separate from the data that code manipulates. This factoring makes it much easier to localize your app, tweak its appearance, and perform other tasks without rewriting any code. For information about the types of resources found in a typical iOS app and how they are used, see “The App Bundle” and “App-Related Resources.”
提交到app store的app都希望有具体的资源,比如图标和启动图片让所有用户感觉更好些。好的评分的app也会使用许多资源文件来保持他们的代码从代码维护的数据中分离开。这些因素使得它更容易的本地化你的app,调整它的外观,执行其他的任务而不需要重写代码。关于在一个典型iOS app中找到的资源类型和如何使用他们,参考"The App Bundle"和"App-Related Resources."


7 As needed, implement any app-specific behaviors that are relevant for your app.
There are many ways to modify the way your app launches or interacts with the system. For information about the most common types of app customizations, see “Advanced App Tricks.”
7 作为需要,实现任何app相关的行为,这些行为与你的app相关。
有许多方法可以用来修改你的app启动方式或者与系统的交互。关于大多数app定制的类型,参考"Advanced App Trricks."


8 Add the advanced features that make your app unique.
iOS includes many other frameworks for managing multimedia, advanced rendering, game content, maps, contacts, location tracking, and many other advanced features. For an overview of the frameworks and features you can incorporate into your apps, see iOS Technology Overview.
8 添加高级特性,使得你的app独特
iOS包括许多其他的框架,比如管理多媒体,高级渲染,游戏内容,地图,接触,位置追踪和许多其他的高级特性。关于框架的概览和你可以纳入你的app的特性,参考"iOS Technology Overview."


9 Do some basic performance tuning for your app.
All iOS apps should be tuned for the best possible performance. Tuned apps run faster but also use system resources, such as memory and battery life, more efficiently. For information about areas to focus on during the tuning process, see “Performance Tuning.”
9 为你的app做一些基础的性能调整
所有的iOS apps都应该为最好的性能做出调整。调整apps运行的更快,更加有效的使用系统资源,比如内存和电池寿命。关于调整的步骤的过程中所关注的方面,参考"Peformance Tuning."


 10 Iterate.
 10 重复
App development is an iterative process. As you add new features, you might need to revisit some or all of the preceding steps to make adjustments to your existing code.
App开发是一个重复的过程。因为你添加新的特性,你可能需要重新访问一些或者所有的处理步骤来为你已经写好的代码做出调整。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值