版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、<p> 學(xué)號:07416522</p><p> 畢業(yè)設(shè)計(論文)外文翻譯</p><p><b> (2011屆)</b></p><p> 外文題目 Introduction to the iPhone </p><p> 譯文題目
2、 iPhone 說 明 書 </p><p> 外文出處 WowBook.Com </p><p> Introduction to the iPhone</p><p> We are about to study
3、 the idea of a computational process. Computational processes are abstract beings that inhabit computers. As they evolve, processes manipulate other abstract things called data. The evolution of a process is directed by
4、a pattern of rules called a program. People create programs to direct processes. In effect, we conjure the spirits of the computer with our spells.</p><p> The iPhone is one of the most distinctive game pla
5、tforms currently available. The touch</p><p> screen, integration with iTunes, programming in Objective-C, low development cost,</p><p> and ease of publishing all make for a very strange but
6、promising new development</p><p> opportunity. As the newest kid on the block, the iPhone instantly captured a noticeable</p><p> portion of the mobile phone market and inspired a wave of copy
7、cat devices by makers</p><p> such as Motorola, Samsung, and LG.</p><p> As a programmer, you might not be impressed with sales figures and market shares,</p><p> but you should
8、be interested in the viability of the iPhone as a whole. If no one owns</p><p> an iPhone, no one will buy the games you make for it. The good news is that even in</p><p> the face of the 2009
9、 economic downturn, iPhones continued to sell.</p><p> To get started with the iPhone, you’ll need to get a free Apple developer account. Next</p><p> you’ll download the iPhone SDK on your Ma
10、c, which also contains the Xcode IDE and</p><p> Interface Builder tool for laying out screens. (Apple doesn’t provide a toolkit for Windows</p><p> or any other non-Mac platform.) And because
11、 the iPhone API requires you to</p><p> write in Objective-C, you will need to read a primer on the language if you do not</p><p> already understand it. This chapter takes you step by step th
12、rough all of these tasks.</p><p> Apple Developer Account and Downloading the SDK</p><p> The first step in setting up your iPhone development environment is to register an Apple</p>&l
13、t;p> developer account. Signing up for an account is free and gives you access to Apple’s</p><p> online documentation, tutorial videos, and the SDK download:</p><p> 1. Go to http://devel
14、oper.apple.com/iphone/.</p><p> 2. Click the Register link, and then click Start Now. Choose the option to create a</p><p> new Apple ID, or to log in using an Apple ID from an iTunes or App S
15、tore account.</p><p> 3. Once you have registered, you can log in to the iPhone Dev Center.</p><p> 4. Apple may already have emailed you a link to download the free SDK, or you may</p>
16、<p> choose to download the SDK using the link from the website. Note that you should</p><p> not download Xcode separately because it is included within the SDK download</p><p> packag
17、e (and the version of Xcode that comes with the SDK may be newer than</p><p> what is otherwise available).</p><p> 5. Once downloaded, install the SDK, which will make Xcode and Interface Bui
18、lder</p><p> accessible to you in the /Developer/Applications folder on your hard drive (you can</p><p> also activate Spotlight and search for Xcode and Interface Builder to launch either<
19、/p><p> application quickly).</p><p> The free developer account will allow you to build applications and run them in a</p><p> simulator on your Mac. However, to load your applicat
20、ion onto a phone, you will also</p><p> need to sign up for the paid developer program. This requires a small annual fee, so</p><p> even if you are a private developer, it won’t hurt your wal
21、let too much:</p><p> 1. Go to http://developer.apple.com/iphone/program/apply.html.</p><p> 2. You will have two options: Standard Program and Enterprise Program. If you are</p><p&
22、gt; writing games for the general public, you probably do not want the Enterprise</p><p> Program. If you read closely, you will notice the Enterprise Program is actually for</p><p> creating
23、 applications that only you and your company will use internally. If you</p><p> plan to create games that will be sold via the App Store, rest assured that the</p><p> Standard Program is the
24、 correct choice for you.</p><p> 3. Select Enroll Now and log in if necessary.</p><p> 4. You now have another choice: enroll as an individual or as a company. If you</p><p> cho
25、ose Individual, you will not be able to add other programmers or quality assurance</p><p> members to your account, which is necessary to distribute your application</p><p> to others during t
26、he development and testing process. However, if you select Company,</p><p> you will be required to provide detailed information about your company.</p><p> 5. Continue through the website, se
27、lecting the appropriate information, until you</p><p> arrive at a screen that says “Thank you for submitting your enrollment.””Now you</p><p> must wait for an email from Apple (which may tak
28、e on the order of a month to</p><p><b> arrive).</b></p><p> Signing up for the paid developer program will also give you access to</p><p> beta releases of future ve
29、rsions of the iPhone OS and SDK, but only</p><p> during the times at which Apple chooses to make them available.</p><p> It is good to get your paid developer account enrollment going as soon
30、 as possible so</p><p> that it will be available when you actually need it.</p><p> Application Bundles</p><p> When you build an application using Xcode, the end result is call
31、ed an application</p><p> bundle. In Mac OS X and the iPhone, an application bundle is a special type of directory</p><p> 2 | Chapter 1: Introduction to the iPhone</p><p> Downl
32、oad at WoweBook.Com</p><p> that holds an executable file and the resources needed to run it. This includes an icon</p><p> to represent the application, files with special information about t
33、he application, and</p><p> any images or sounds the application uses.</p><p> In the Finder, an application bundle simply appears as its application</p><p> icon; right-click or
34、 Ctrl-click on it and select View Package Contents</p><p> from the menu to see what’s inside.</p><p> Although you can’t do this on the iPhone, you can find iPhone applications</p><
35、;p> in the iPhone Simulator. If you have the iPhone SDK installed,</p><p> you can use Spotlight to search for the MobileSafari.app file. Show this</p><p> file in the Finder (don’t try to
36、 run it on your Mac), and view its package</p><p> contents (some of which appears in the following list).</p><p> A typical iPhone application bundle might have the following structure:</p
37、><p> Executable</p><p> (Required.) This is the compiled code executable; it will typically have the same</p><p> name as your application. In MobileSafari.app, this is the file na
38、med MobileSafari.</p><p> Info.plist</p><p> (Required.) This is a collection of properties, in key-value pair form, that specifies</p><p> important information about your appli
39、cation. Notable properties listed here are</p><p> the display name of your application, the version number, and a unique ID number.</p><p> These files use a binary format that can’ be read i
40、n a text editor, but you can use</p><p> the Property List Editor located in /Developer/Applications/Utilities to view them.</p><p><b> icon.png</b></p><p> (Required
41、.) This is a 57 *57 pixel icon used to represent your application on the</p><p> iPhone’ home screen. Glossy button effects will be added on top of this image</p><p> automatically, so it shou
42、ld be flat-colored.</p><p> Various resources</p><p> (Optional.) All common resource files, such as images, sounds, and binary data,</p><p> used by your application will be pla
43、ced in the same folder as the executable. The</p><p> only subfolders present in an iPhone application bundle are for localized resources.</p><p> Localization folders</p><p> (O
44、ptional.) If your application supports multiple languages, you may add subfolders</p><p> to the bundle, which contain resources that cater to individual languages.</p><p> The folder names wi
45、ll have a language name or an ISO language abbreviation followed</p><p> by .lproj; for example, English.lproj, French.lproj, German.lproj, and</p><p> uk.lproj would each contain resources sp
46、ecific to English, French, German, and</p><p> UK English languages, respectively.</p><p> Settings.bundle</p><p> (Optional.) You will create this file if you want your applicat
47、ion to provide user</p><p> preference options in the Settings application that comes with the iPhone.</p><p> Icon-Settings.png</p><p> (Optional.) If you added a Settings.bundl
48、e file, this image is used to represent the</p><p> application in the Settings application. The image should be 29 *29 pixels. However,</p><p> if you do not add this image, the Icon.png imag
49、e will be scaled and used</p><p> automatically.</p><p> MainWindow.nib</p><p> (Optional.) Created by the Interface Builder application, MainWindow.nib contains</p><p
50、> code and resources necessary to draw your application as it starts up.</p><p> More .nib files can be loaded after this one, but it will always be the first in memory.</p><p> Default.pn
51、g</p><p> (Optional.) This image is displayed as the application is loading the Main-</p><p> Window.nib file. It should be full screen, which is 480 *20 pixels on the iPhone.</p><p
52、> If this image is close to what the user will see when the application is finished</p><p> loading, the load process will appear to take less time.</p><p> iTunesArtwork</p><p&
53、gt; (Optional.) If you are distributing the application outside the App Store, this artwork</p><p> is used to display your application when loading onto a handset using iTunes.</p><p> More
54、on this later.</p><p> As you will see in the next section, when you’re creating your application, Xcode and</p><p> Interface Builder will create most of these files for you.</p><p
55、> Xcode and Interface Builder</p><p> If you are unfamiliar with Xcode, you may be reluctant to learn a new IDE at first.</p><p> However, the way iPhone development works, you pretty much
56、 have to. Fortunately,</p><p> once you get used to it, you’ll see that Xcode is pretty good at what it does. It has all</p><p> the features you would expect from an industry-standard IDE: it
57、 jumps to the line of</p><p> compile errors, auto-completes complicated API methods, and has integrated SDK</p><p> references.</p><p> And it gets better: Xcode supports on-dev
58、ice debugging, a full-featured iPhone Simulator,</p><p> useful project wizards, refactoring tools, and even direct integration with Subversion</p><p> revision control repositories.</p>
59、<p> An Xcode project contains all the code, resources, certificates, and configurations you</p><p> need to create an iPhone application. To get acquainted with the environment, open</p><
60、;p> your Xcode IDE and follow these steps to create a typical “Hello World” application:</p><p> 1. Open Xcode.</p><p> 2. Select File →New Project.</p><p> 3. In the dialog
61、that opens, select iPhone OS, then View-Based Application (see Figure</p><p> 1-1), and click Choose.</p><p> 4. Name the project “HelloWorld” and click Save.</p><p> 5. At this
62、point, you can build and run (click the Build and Go icon in the toolbar).</p><p> The HelloWorld application shows only a blank gray screen when run in the Simulator,</p><p> as shown in Figu
63、re 1-2.</p><p> Figure 1-1. Selecting View-Based Application</p><p> Not very interesting yet, is it? Before we go on to make this a proper “Hello World”</p><p> application, her
64、e is a quick rundown of the files that were generated when you created</p><p> the project:</p><p> HelloWorldAppDelegate.m, HelloWorldAppDelegate.h</p><p> The class held in the
65、se files can be considered the main code entry point of the</p><p> application. The app delegate controls the main window and main View Controller,</p><p> and is responsible for setting them
66、 up for display.</p><p> HelloWorldViewController.m, HelloWorldViewController.h</p><p> This class in these files holds the main view, and is responsible for showing the</p><p>
67、horribly uninteresting gray screen. We will be editing it to say “Hello World” soon.</p><p> Figure 1-2. Empty application in the Simulator</p><p> MainWindow.xib</p><p> This In
68、terface Builder file results in a .nib file that is placed in your application</p><p> bundle when the project is compiled. When loaded, it creates the app delegate,</p><p> and loads the main
69、 window and View Controller.</p><p> HelloWorldViewController.xib</p><p> This file lays out the design for the HelloWorldViewController’s view.</p><p> NIB stands for NeXTSTEP I
70、nterface Builder, and XIB stands for Xcode</p><p> Interface Builder. NIB files are dense compiled binary files; XIB files are</p><p> human-readable XML files. As we mentioned earlier, Xcode
71、compiles</p><p> XIB files into NIB files. The XIB format was created specifically to solve</p><p> issues with merging NIB files in projects under source control, since you</p><p&g
72、t; can diff XML files more easily than binary files.</p><p> Now we need to draw the “Hello World” text. We can go about this in several ways:</p><p> . Add a Cocoa UILabel by writing code di
73、rectly in HelloWorldViewController.m.</p><p> . Add a Cocoa UILabel in Interface Builder to HelloWorldViewController.xib.</p><p> . Define a subclass of UIView, and use a Quartz font rendering
74、 in drawRect.</p><p> . Create a texture-mapped font in OpenGL ES to render with.</p><p> Let’s start with the first method: adding a UILabel by writing code in HelloWorldView-</p><
75、p> Controller.m. A stub method named viewDidLoad is already inside HelloWorldView-</p><p> Controller.m, which is a good place to add our code. This method will be called</p><p> after .ni
76、b file loading is done, but before rendering begins:</p><p> 1. Replace the viewDidLoad function in HelloWorldViewController.m with the following</p><p> (this function is commented out by def
77、ault, so be sure to remove the /* that</p><p> precedes it and the */ that follows it):</p><p> - (void) viewDidLoad {</p><p> [super viewDidLoad];</p><p> //draw &
78、quot;Hello World" using Cocoa UIKit.</p><p> //grab the screen dimensions</p><p> int w = self.view.frame.size.width;</p><p> int h = self.view.frame.size.height;</p>
79、<p> //create a text label: the size 100,50 here is arbitrary</p><p> // but it must be large enough to fit the "Hello World" text.</p><p> UILabel* label = [[UILabel alloc] i
80、nitWithFrame:CGRectMake(0, 0, 100, 50)];</p><p> //put the label at the center of the screen</p><p> label.center = CGPointMake(w/2, h/2);</p><p> //align the text to the center
81、of the label (default is left)</p><p> label.textAlignment = UITextAlignmentCenter;</p><p> //don't draw the label's background (default is white)</p><p> label.backgroun
82、dColor = [UIColor clearColor];</p><p> label.text = @"Hello world!";</p><p> //add label to our view, so that it can be rendered</p><p> [self.view addSubview:label];&l
83、t;/p><p> //since we alloc'd label in this method we need to release label here</p><p> [label release];</p><p><b> }</b></p><p> 2. Build and run the
84、project (if you haven’t quit the Simulator from its previous run,</p><p> you’ll be prompted to stop it). The app should now display your text (see Figure</p><p><b> 1-3).</b></
85、p><p> Figure 1-3. “Hello world!” text shown</p><p> Now let’s go over the second method, adding a UILabel to HelloWorldViewController.</p><p> xib using Interface Builder. You must
86、 undo your changes if you followed the preceding</p><p><b> example:</b></p><p> 1. Open the HelloWorldViewController.xib file in Interface Builder by double-clicking</p>&l
87、t;p> it from the list of project files in Xcode.</p><p> 2. Double-click the View object to begin editing it (Figure 1-4).</p><p> Figure 1-4. Double-clicking the View object to edit the f
88、ile</p><p> 3. Find the Label object in the Library panel (open the panel by selecting</p><p> Tools仺Library Panel, if it is not already open). See Figure 1-5.</p><p> 4. Drag th
89、e label into the View editing window, as shown in Figure 1-6.</p><p> 5. Double-click the new label and edit the text to say “Hello World”. You can also</p><p> edit it from the Attributes Ins
90、pector (Tools仺Attributes Inspector).</p><p> 6. In the Label Size Inspector (Tools Size Inspector), click both of the Placement</p><p> buttons to center the label horizontally and vertically,
91、 as shown in Figure 1-7.</p><p> 7. Save the .xib file and return to Xcode. Building the application will update</p><p> the .nib file, which will cause the changes to appear when the applicat
92、ion is run,</p><p> as shown in Figure 1-8.</p><p> 8. When the .nib file is loaded, it creates and displays the UILabel. If our code needs</p><p> access to read or modify the c
93、reated label, we can link it to an IBOutlet in our code.</p><p> In HelloWorldViewController.h, replace the stub definition of HelloWorldViewCon</p><p> troller with the following:</p>
94、<p> @interface HelloWorldViewController : UIViewController {</p><p> IBOutlet UILabel* myLabel;</p><p><b> }</b></p><p> An IBOutlet is a code tag that enables
95、 Interface Builder to recognize possible handles</p><p> in code that can be linked to.</p><p> Figure 1-5. Selecting Label from the Objects Library</p><p> 9. To link the .nib’s
96、 label to the outlet, open HelloWorldViewController.xib in Interface</p><p> Builder and open the Connections Inspector (Tools Connections Inspector).</p><p> Then, click to select the label,
97、drag the label’s New Referencing Outlet to the File’s</p><p> Owner object, release, and click on the “myLabel” text that shows up in the</p><p> Apple Developer Account and Downloading the SD
98、K | 9</p><p> Download at WoweBook.Com</p><p> pop-up menu (see Figures 1-9 through 1-11). Because we set the Referencing Outlet,</p><p> the two objects will be linked together
99、when the .nib is loaded. Specifically,</p><p> when HelloWorldViewController.nib is loaded in the application, it will know to</p><p> set the variable myLabel to point at the UILabel we just
100、linked to.</p><p> 10. Save HelloWorldViewController.xib and quit Interface Builder.</p><p> Now our code has access to the label through myLabel. This linking process is used</p><p
101、> frequently in Interface Builder to specify outlets, actions, delegates, and data sources.</p><p> Any interaction between visible elements of the interface and your code is made via</p><p&g
102、t; Interface Builder links.</p><p> Figure 1-6. Adding a new label to the view</p><p> Figure 1-7. Modifying the Label object properties</p><p> Figure 1-8. “Hello World!” text
103、with Label object</p><p> Figure 1-9. The Label Connections window</p><p> Figure 1-10. Clicking and dragging from New Referencing Outlet to File’s Owner</p><p> Views and Contro
104、llers</p><p> The UIView class represents a View object in the iPhone SDK. Views are visible rectangular</p><p> portions of the screen that handle drawing and animation, event handling, and&l
105、t;/p><p> subview management. If you look at the iPod application that comes with your iPhone,</p><p> you’ll see that the navigation bar at the top, the tab bar at the bottom, and the content<
106、;/p><p> area in the middle are three separate views.</p><p> When creating a view-based application in the New Project Wizard, start with a single</p><p> View Controller and a sin
107、gle View. You may want more Views as your application</p><p> becomes more complex. For example, you may have one View for your game, another</p><p> for a Main menu, one for a Settings screen
108、, and another for an online High Score screen.</p><p> If your Views share a lot of the same code, it makes sense to add those Views to the</p><p> same View Controller, along with the shared
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 眾賞文庫僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 電氣類畢業(yè)設(shè)計外文翻譯
- 電氣類畢業(yè)設(shè)計外文翻譯3
- android手機圖像瀏覽軟件畢業(yè)設(shè)計(含外文翻譯)
- android手機圖像瀏覽軟件畢業(yè)設(shè)計(含外文翻譯)
- android手機圖像瀏覽軟件畢業(yè)設(shè)計(含外文翻譯)
- 電氣類畢業(yè)設(shè)計外文翻譯---直接轉(zhuǎn)矩控制
- 機械類畢業(yè)設(shè)計外文翻譯--軸承壽命分析
- 畢業(yè)設(shè)計外文翻譯
- 軸承壽命分析-機械類畢業(yè)設(shè)計外文翻譯
- 網(wǎng)站畢業(yè)設(shè)計外文翻譯
- 電氣畢業(yè)設(shè)計外文翻譯
- 混凝土畢業(yè)設(shè)計外文翻譯
- lyx畢業(yè)設(shè)計外文翻譯
- led畢業(yè)設(shè)計外文翻譯
- 工程畢業(yè)設(shè)計外文翻譯
- 倉儲畢業(yè)設(shè)計外文翻譯
- 機械畢業(yè)設(shè)計外文翻譯
- 畢業(yè)設(shè)計外文翻譯.doc
- 畢業(yè)設(shè)計外文翻譯.doc
- 畢業(yè)設(shè)計外文翻譯.doc
評論
0/150
提交評論