You are on page 1of 90

i

Amazon

iPhone

iPhoneCocoaChina

Dave MarkMaciPhone
iPhoneiPhone

Brian GreenstonePangeaCEO
Trism225iPhone
DaveJeff

Steve Demeter2008iPhoneTrism

AppleiPhoneApp Store
iShoot
Ethan Nicholas2TrismSteve Demeter10

ii

Amazon
20
AppleiPhone SDK
iPhoneiPhone
SQLiteQuartzOpenGL ESCore Location
iPhone

iPhone

Dave Mark AppleMac


Learn C on the MacMacintosh Programming PrimerUltimate Mac
Programmingwww.davemark.com
Jeff LaMarche AppleMacTech Magazine
Apple

iii


iPhone
iPhoneSDK
iPhone SDKiPhoneiPod Touch

iPhone SDKiPhoneObjective-CXcode
Interface BuilderiPhone

iPhoneiPhone

1834iPhone
iPhone516
iPhone
Core LocationiPhone

iPhone
Objective-CiPhone

iPhoneSDKiPhone
iPhone

20091

Mac
iPhone

App Store
iPhoneiPhone

http://iphonedevbook.com

DaveJeff


1 iPhone
1
1.1

1
1.2

1
1.3

3
1.4
iPhone
1.4.1

1.4.2

4
1.4.3

4
1.4.4

4
1.4.5

5
1.4.6

5
1.4.7
Cocoa
5
1.4.8

5
1.4.9

6
1.5

6
1.6

7
2
8
2.1
Xcode
8
2.2
Interface Builder
12
2.2.1
nib
14
2.2.2

15
2.3
iPhone
17
2.4

20
3
21
3.1

21
3.2

22
3.3

22
3.3.1

23
3.3.2

23
3.3.3

3.3.4

3.4

30
3.5
MainWindow.xib
32
3.6
Button_FunViewController.xib
3.6.1
Interface Builder
3.6.2

35
3.6.3

37
3.7

38
4
39

4
4

24

26

33
33

4.1
4.2
4.3
4.3.1
4.3.2
4.3.3
4.3.4
4.3.5
4.3.6
4.4
4.4.1
4.4.2
4.5
4.5.1
4.5.2
4.5.3
4.5.4
4.5.5
4.6
4.6.1
4.6.2
4.6.3
4.6.4
4.7

39

41

41

41

42

43

46

49

49

49

50

51

52

52

52

52

53

54

55

55

55

57

58

59

4.7.1

4.7.2
Interface Builder
4.7.3

60
4.8

61
4.9

63
4.9.1
viewDidLoad
64
4.9.2

65
4.9.3

65
4.10

65
5
67
5.1

68
5.1.1

68
5.1.2

70
5.1.3

70
5.1.4

72
5.2

73
5.2.1

74

59
60

5.2.2

74
5.3

77
5.3.1

78
5.3.2

78
5.3.3

79
5.3.4

79
5.3.5

80
5.3.6
Core Graphics
83
5.4

85
6
86
6.1
View Switcher
88
6.2

88
6.2.1

89
6.2.2

89
6.3
View Switcher
89
6.3.1
nib
90
6.3.2

92
6.3.3
SwitchViewController.h
93
6.3.4
MainWindow.xib
93
6.3.5
SwitchViewController.m
96
6.3.6

99
6.4

101
6.5

103
6.6

105
7
106
7.1
Pickers
106
7.2

108
7.3

108
7.3.1

108
7.3.2
nib
109
7.3.3

109
7.4

113
7.5

116
7.5.1

116
7.5.2

116
7.5.3

117
7.6

121
7.6.1

121
7.6.2

122
7.6.3

122
7.7

125

7.8

132
7.8.1

132
7.8.2

133
7.8.3

133
7.8.4

133
7.8.5
spin
136
7.8.6
viewDidLoad
137
7.8.7

139
7.8.8
Audio Toolbox
142
7.9

143
8
144
8.1

144
8.2

147
8.2.1

147
8.2.2

148
8.3

151
8.4

151
8.4.1

152
8.4.2

152
8.4.3

153
8.4.4

155
8.5

155
8.5.1

155
8.5.2

155
8.5.3
UITableViewCell
8.6

163
8.6.1

163
8.6.2

163
8.6.3

164
8.6.4

167
8.7

168
8.7.1

168
8.7.2

168
8.7.3

170
8.7.4

171
8.7.5

172
8.8

180
9
181
9.1

181
9.1.1
181
9.1.2

182

159

9.2
6 Nav
182
9.3
Nav
184
9.3.1

185
9.3.2

185
9.4
1
191
9.5
2
198
9.6
3
202
9.7
4
207
9.7.1

208
9.7.2

208
9.8
5
213
9.9
6
218
9.9.1

219
9.9.2

221
9.9.3

224
9.10

238
9.11

240
10
241
10.1

241
10.2
AppSettings
242
10.3

243
10.4

245
10.4.1

245
10.4.2

246
10.4.3

247
10.4.4

249
10.4.5

249
10.4.6

250
10.4.7

251
10.4.8

252
10.5

253
10.6

257
10.7

259
11
260
11.1

260
11.1.1
Documents
261
11.1.2
tmp
262
11.2

262
11.2.1

262
11.2.2

262
11.3

263

11.4

264
11.4.1

264
11.4.2

265
11.4.3

265
11.4.4

269
11.4.5
NSCopying
270
11.5

272
11.5.1
FourLines
272
11.5.2
PersistenceViewController
273
11.6
iPhone SQLite3
276
11.7

284
12 Quartz OpenGL
285
12.1

285
12.2

286
12.3
Quart
286
12.3.1
Quartz 2D
286
12.3.2

287
12.3.3

287
12.3.4

289
12.3.5

289
12.3.6
Quartz 2D
12.4
QuartzFun
290
12.4.1

291
12.4.2

291
12.4.3
QuartzFunView
292
12.4.4

294
12.4.5
QuartzFunViewController.xib
297
12.4.6

298
12.4.7

299
12.4.8

301
12.5
OpenGL ES
306
12.6

316
13
317
13.1

317
13.2

318
13.3

319
13.4

320
13.5
Swipe
324
13.6

327
13.7

329
13.8

333

289

13.9

336
13.10

339
14 Core Location
14.1

340
14.1.1

341
14.1.2

341
14.1.3

341
14.1.4

341
14.2

342
14.2.1

342
14.2.2
CLLocation
342
14.2.3

343
14.3
Core Location
344
14.3.1

347
14.3.2

348
14.4

349
15
350
15.1

350
15.2

351
15.2.1
UIAcceleration
351
15.2.2
accelerometer:didAccelerate:
15.3

354
15.3.1

355
15.3.2

358
15.3.3

359
15.4

359
15.4.1
Ball View
360
15.4.2
Ball View
361
15.4.3

364
15.5

366
16 iPhone
367
16.1
UIImagePickerController
16.2

368
16.3

370
16.3.1

370
16.3.2

371
16.4

374
17
375
17.1

375
17.2

376
17.3
iPhone
378

340

353

367

17.3.1

381
17.3.2
LocalizeMe
381
17.3.3
nib
382
17.3.4

383
17.3.5

385
17.3.6

386
17.3.7

386
17.4

388
18
390
18.1

390
18.1.1

390
18.1.2

391
18.1.3

391
18.1.4

391
18.1.5

391
18.1.6

392
18.2

392

TerryDeneen

Apress
ClayAndresApressDominic Shakeshaft
Laura Esterman

Heather Lang
Grace WongKari Brooks-Copony
Kelly WinquistWordPete Aylward
Apress
Mark DalrympleMark

MaddieGwynnieIanKaiDanielKelleyRyan

1.2

1
2

iPhone

3
4

5
iPhoneiPhone

iPhone

1.1

iPhoneiPhone

6
7
8

iPhone
iPhone

1.2

9
10
11

iPhoneLeopardOS
X 10.5.3IntelMacintosh 2006Macintosh 12

MacBookMac Mini 13
RAM
iPhoneiPhone SDK 14

15
http://developer.apple.com/iphone/http://www.apple.com.cn/
developer/iPhone/1-11-1
iPhone SDK3
16
Download the Free SDKApple ID
Apple IDApple IDCreateApple IDApple ID
17
iPhoneSDK
iPhone
18

1 iPhone

1-1 iPhone

iPhone SDKXcodeIDE
Xcode
Xcode
SDKMaciPhone
iPhoneiPhoneiPod
TouchiPhoneApp Store

iPhone

1.3

99
App StoreiPhone

299iPhoneiPod Touch
http://developer.apple.com/iphone/program/
iPhone
iPhoneMacMac

iPhone
99IDEVisual Studio

iPhoneiPhone
iPhone

1
2
3
4
5
6
7
8


iPhoneiPod Touch
iPhone

9
10

1.3

11

Objective-C SDKCocoa Touch


Objective-C 2.0Objective-C
2.0
iPhoneiPhone
iPhoneiPhone
Objective-C

12
13
14
15

Objective-C
MacMark DalrympleScott KnasterLearn Objective-C on the

16

Mac Objective-C
http://www.apress.com/book/view/9781430218159

17
18

1 iPhone

Apple iPhoneThe Objective-C 2.0 Programming Language


Objective-C2.0
http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/ObjectiveC

iPhone

1.4

CocoaNextSTEPCocoa Touch
iPhone.NETJava

CocoaNextSTEPiPhone SDK
Mac OS X
CocoaCocoa Touch

iPhone

1.4.1

iPhoneiPhone

1.4.2

iPhone
iPhone

1.4.3

iPhone
iPhone

iPhone

1.4.4

iPhone

1.4

iPhone

1
homeiPhone
2
5

iPhone
3

1.4.5

iPhone
iPhone480320 5
iMac16801050MacBook
1280800 30Cinema Display256016006

1.4.6

128 MB4 GB
iPhone
8
48 KB
iPhoneiPhone128 MB
9

10
64 MBiPhone
Mac OS X
11
iPhone
OS
12

Cocoa Touch

13

1.4.7

Cocoa

14

iPhoneCocoaiPhone
iPhone SDKCore DataCocoa Binding Cocoa Touch 15
Objective-C 2.0iPhoneCocoa Touch
16

1.4.8

17

Cocoa TouchCocoaiPhone SDKCocoa


MaciPhone SDK

18

1 iPhone

Core LocationiPhone
SDKiPhoneiPhone

1.4.9

iPhone
iPhone

1.5

2XcodeInterface BuilderiPhone

43iPhone

5iPhone
6

7iPhone
8

9iPhone

10iPhone

11iPhone
iPhoneSQLite
12Quartz
OpenGL ES
13iPhone

14iPhoneCore LocationCore Location


iPhone

1.6

15iPhoneiPhone

16iPhone

17iPhone70

18iPhone
iPhone SDK

1.6

iPhoneiPhone

1
2
3
4
5
6

iPhone
Cocoa Touch
iPhone SDKiPhone SDK

7
8

iPhone

10
11
12
13
14
15
16
17
18

144

iPhone

YouTubeSettingsiPod
8-1

8-1 SettingsiPodYouTube

8.1

iPhone
iPhone
UITableView
UITableViewCell
8-2

8.1

145

1
2
3
4
5
6
7
8-2 UITableViewUITableViewCell

UITableViewDelegateUITableViewDataSource

18-1YouTube
23
UITableViewCell
UITableViewCell

UITableViewCellUITableViewCell

8-3

8-3

8
9
10
11
12
13
14
15
16
17
18

146

8-3

section
8-48-3
AB

8-4

8.2

147

2
26

iPhone Human Interface GuidelineiPhone

3
4

8.2

Xcode
Simple Table

8.2.1

6
7
8

ResourcesClasses
9
Simple_TableViewController.xibInterface BuilderView
Table View8-5View
10
View8-6

11

12
13
14
15
8-5

8-6 View

View

16
17

Files Owner
Xcode

18

148

8.2.2

Simple_TableViewController.h

Simple_TableViewController.m

8.2

149

1
2
3
4
5
6
7
8
3ViewDidLoad

URL
tableView:
numberOfRowsInSection:
1

9
10
11
12

13

NSIndexPathNSIndexPath

int
tableView

14
15

16

iPhone 17
UITableViewCellUIView
18

150

NSString
SimpleTableIdentifier

cellnil

textlistData
text

indexPath
text

CGRectZeroCore Graphics Core


Graphics
5

8-7

8-7

8.4

8.3

151

UITableViewCell

08 Simple Tablestar.png
Resourcesstar.png
Simpe_TableViewController.m tableView:cellForRowAtIndexPath:

2
3
4

5
6

7
8
9
10
11
12
image

8-8

8.4

13
14
15

UITableViewDelegate

16
8-8 image

17
18

152

8.4.1

Simple_TableViewController.m@end
declaration

0
011

8-9

8.4.2

Simple_TableViewController.m@end

8-9

indexPath
nil

8.4

153

indexPath

Simpe_TableViewController.m@end

2
3
4

5
6
7
8
9
10

8-10
indexPath
/

indexPathnil

8.4.3

11
12
13
14

tableView:cellForRowAtIndexPath:

15
8-10

16
17

18

154

8-11

@end

180
8-12

8-11

8-12

8.5

8.4.4

155

UITextViewDelegate

8.5

UITableViewCell

1
2
3
4

UITableViewCellUITableViewCell

8.5.1

8-13

8.5.2

5
6
7
8

Xcode 8-13
CellsCellsViewController.xibTable

View
Files OwnerXcode8.6.1
1.
CellsViewController.h

10
11
12
13
14
15
16
17
18

156

tag42

2.

CellsViewController.m

8.5

157

1
2
3
4
5
6
7
8

9
10
11
12
13
14

15
16
17
18

158

viewDidLoad
NameColor

tableView:cellForRowWithIndexPath:

4UILabel
contentViewUIView4UIView

contentView
NameLabelName:colorLabelColor:

kNameValueTagnameValuetag

8.5

159

indexPath
/

2
3

5
8-13

Interface Builder

8.5.3

UITableViewCell

Interface BuilderInterface Builder


UITableViewCell
nib
nib

XcodeCtrl+ClassesAddNew File

Cocoa Touch Classes

6
7
8
9
10
11

UITableViewCellNextCustomCell.mAlso Create
CustomCell.h
XcodeResourcesAddNew File
User InterfacesEmpty XIB
CustomCell.xib
1. UITableViewCell
UITableViewCell

tag

CustomCell.h

12
13
14
15
16
17
18

160

CustomCell.m

2. Interface Builder
CustomCell.xibInterface Builder
Files ownerFirst
Responder8-14

UITableViewCellCustomCell

4465

8-14

8.5

161

Identifier

SimpleTableIdentifier IdentifierCustomCell-

IdentifierAccessory

Detail DiscloureNone8-15

UITableViewCellUIView

Custom Cell
Content View
8-16
Interface Builder
ViewCustom Cell

x0
y0w320h65View
Custom Cell

Interface Builder
4Custom Cell8-17

Name:Color:

ControlCustom Cell
nameLabelControl
Custom Cell
colorLabel
Files Owner

6
7
8

9
10

8-15

11
12

8-16

13
14
15

8-17

nib
nibXcode
3.
CellsViewController.m talbeView:cellForRowAtIndexPathtalbeView:cellForRowAtIndexPath

16
17
18

162

CellsViewController.m
nibnib
objectAtIndex:100
First ResponderloadNibNamed:owner:options:
1

CellsViewController.m
@end

CustomCell.htag

Interface Builder

8.6

163

8.6

Xcode
Sections

8.6.1

2
3

ClassesResourcesInterface Biulder
SectionsViewController.xib
View
Files Owner

StyleIndexedGrouped8-18

Xcode

8.6.2

8-18

08 Sections
10
sortednames.plistResource
sortednames.plist8-19
11

12
13
14
15
16
17
8-19 sortednames.plist

18

164

8.6.3

SectionsViewController.hNSDictionaryNSArray

UITableViewDataSourceUITableDelegate

SectionsViewController.m

8.6

165

1
2
3
4
5
6
7
8

9
10
11
12
13
14

15
16
17
18

166

viewDidLoad
NSDictionarynames
NSArray NSDictionary
26AZ

tableView:cellForRowAtIndexPath:

Simple Table
TalbeView:titleForHeaderInSection

SectionViewController.mCGRectZeroCore Graphics
Groups & FilesFrameworksProjectAdd to Project
5
Grouped

8.6

167

268-20

Interface BuilderSectionViewController.xib
IndexedXcode
8-21

8.6.4

2
3

2000ZacharianZebedian
Zojirishu

SectionsViewController.m@end

5
6

7
8

0
8-22

9
10
11
12
13
14
15
16
17

8-20

8-21

8-22

18

168

8.7

Arabella

iPhone8-23

8.7.1

8-23

Mark DalrympleScott KnasterLearn Object-CApress2009

8.7.2

NSDictionary NSMutableCopying
NSMutableDictionarymutableCopy
NSMutableDictionary

Objective-C
NSDitionaryNSMutable-

8.7

169

Dictionary

Classes

OtherEmpty File
NSDdictionary-MutableDeepCopy.h
NSDdictionary-MutableDeepCopy.m

NSObject

NSDdictionary-MutableDeepCopy.h

2
3
4

5
6

7
NSDdictionary-MutableDeepCopy.m

8
9
10
11
12
13
14
15
16

NSDictionaryself

mutableDeepCopymutableCopy

17
18

170

Objective-C
Objective-C 2.0NSEnumerator
Learn Objective CNSArray

CocoaNSDctionaryNSArrayNSSet

ret

autorelease

NSDictionary-MutableDeepCopy.h
NSDictionarymutableDeepCopy

8.7.3

NSArrayNSMutableArrayNSDictionaryNSMutableDictionary

UISearchBarDelegate

SectionsViewController.h

8.7

171

1
2
3
4
5
6
7
table search allNames8
nameskeys
Interface Builder

8.7.4

Interface BuilderSectionsViewController. xib

nibTable ViewTable View

Search Bar8-24

8-25
ControlFiles Owner
8-26
Shows Cancel ButtonPlaceholdersearch
Cancel
search
delegateFiles Owner

Xcode

9
10
11
12
13
14
15
16
17
18

172

8-24

8-25

8.7.5

Search Bar

8-26

SectionsViewController.m

8.7

173

1
2
3
4
5
6
7
8

9
10
11
12
13
14

15
16
17
18

174

8.7

175

1
2
3
4
5
6
7
8

9
10
11
12
13
14

15
16
17
18

176

1. allNames

allnames
nameskeyskeys

2.

8.7

177

1
2
3
4

handleSearchForTerm:
handleSearchForTerm: 5

9
keys

10
names

A
A

NSString
NSCaseInsensitiveSearch Aa

NSRangelocationlength
locationNSNotFoundNSNotFound
NSRangeNSNotFound

11
12
13
14
15
16
17
18

178

3. viewDidLoad
viewDidLoadallNamesnames
keysresetSearchresetSearch
nameskeysInterface
Builder

4.
nameskeys

5.

talbeView:willSelectRowAtIndexPath:
indexPath
talbeView:didSelectRowAtIndexPath:

8.7

179

1
2
6.

searchBarSearchButtonClicked:

3
4

nameskeys

5
6
searchBarSearchButtonClicked: 7

live search 8

3
9

2000 10
iPhoneiPod Touch
11

12

searchBar:textDidChange:

13
14
15
16

17
18

180

Cancel

Cancel

8.8

flat table

iPhone

12.1

285

1
2

12

QuartzOpenGL

3
4

5
UIKit

Quartz 2D
Core GraphicsOpenGL ESOpenGL ES
OpenGLOpenGL ESOpenGLOpenGL ESiPhone
ES

12.1

6
7
8
9

QuartzOpenGLQuartz

Quartz

Quartz

OpenGL ES
OpenGL ES
OpenGL
OpenGL ES
OpenGL

10

11
12
13
14
15
16
17
18

286

12

Quartz OpenGL

Quartz
Quartz 2DQuartzQuartz

OpenGL

12.2

12-1
Quartz 2DOpenGL ES

12.3

Quart

Quartz
UIViewdrawRect:
Quartz drawRect:UIView

drawRect:Quartz

12.3.1

12-1

Quartz 2D

Quartz 2DCore Graphics

Quartz

Core Graphics CObjective-CCore GraphicsAPI


CC

Core Graphics
2

12.3 Quart

287

1
2
2
Core Graphics

CGContextMoveToPoint()

(100, 100)12.3.2
Core Graphics

QuartzCGContextStrokePath()

12.3.2

CGContextMoveToPoint()
CGContextLineToPoint()Core Graphics
xy(x, y)(0, 0)y

3
4
5
6

7
8
9
10

x65
(100, 100)(200, 200) 11
12-2
iPhone 12
OpenGL ES(0, 0)y
12-3OpenGLOpenGL 13
OpenGL
QuartzQuartz
14
CGPointCGPointxystruct
QuartzCGSize CGSizewidthheight
structQuartzCGRectCGRect
originCGPointsizeCGSize
widthheight

12.3.3

iPhone UIKit

15
16

17
18

288

12

Quartz OpenGL

Objective-CUIColorCore GraphicUIColor
CGColorUIColor
CGColorCore Graphic
redColorUIColorCGColor

12-2

12-3 OpenGL(100,
100)(200, 200)
12-2

1. iPhone
4
Quartz 2DCGFloat
iPhonefloat01
3RGB
12-43
3

12-4 RGB

RYB
RYB

2.
Quartz 2DOpenGL ESalpha
Alpha
alpha1.0100%
1.0alpha
RGBAalpha

12.3 Quart

289

RGB
HSVHSL
CMYKRGB

UIColorCGColorCore GraphicsOpenGL ES
OpenGL ESRGBAQuartz
UIColorUIColor
redColor

UIColorRGBA

12.3.4

Quartz 2DObjective-CUIImage
Core GraphicsCGImageUIImage

CGPointCGRect
UIImage

12.3.5

Quartz 2D
Quartz
Core Graphics

2
3
4

6
7
8
9
10
11
12
13

14
15
Bezier
QuartzBezierhttp://developer.apple.com/
16
documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_intro/chapter_1_section_1.html
iPhone Dev CenterXcodeQuartz 2D Programming GuideQuartz 2D
12.3.6

Quartz 2D

Quartz 2DOpenGL

17
18

290

12

Quartz OpenGL

Quart 2D
12-5
QuartzDemoQuartz 2D
Quartz 2D

12.4

QuartzFun

XcodeQuartzFun
ClassesResourcesClasses

UIViewdrawRect:
Cocoa Touch ClassesUIView subclassQuartzFunView.m

Other
Empty FileConstants.h

12-5 Quartz 2DQuartz Demo

12.4 QuartzFun

291

12-1
UIColor
Objective-C

1
2

UIColorEmpty FileUIColor-Random.h

UIColor-Random.mNSObject subclassUIColor-Random.m
UIColor-Random.h

12.4.1

UIColor-Random.h

3
4
5
6

UIColor-Random.m

7
8
9
10
11
12
13

iPhone

CGFloat0.01.03
alpha1.0

12.4.2

14
15
16

17

Constants.h

18

292

12

Quartz OpenGL

typedef

12.4.3

QuartzFunView

UIView
QuartzFunView.h

Constants.h

firstTouchlastTouch

ShapeType
UIImage
12-6Boolean

12.4 QuartzFun

293

QuartzFunView.m

2
3
4
5
6

7
8
9
10
11
12

13
14
15
16
17
18

294

12

Quartz OpenGL

nib
initWithCoder:nib

nibinit:initWithFrame:initWithCoder:

useRandomColorNO
13
touchesBegan:withEvent:touchesMoved:withEvent: 12-6
touchesEnded:withEvent:

UIImage

3UIViewiPhone
touchesBegan:withEvent:
UIColorrandomColor

selfsetNeedsDisplay
touchesMoved:withEvent:
lastTouch
touchesEnded:withEvent:
touchesMoved:withEvent:lastTouch

drawRect:

12.4.4

12-1
4
3

12.4 QuartzFun

295

QuartzFunViewController.h

2
3
4
5
QuartzFunViewController.m

7
8
9
10
11
12
13
14
15
16
17
18

296

12

Quartz OpenGL

changeColor:
viewQuartzFunViewcurrentColor

useRandomColorYES

changeShape:
shapeTypesenderShapeType enumenum4
4
ImagecolorControlcolorControl

12.4 QuartzFun

12.4.5

297

QuartzFunViewController.xib

nibQuartzFunView2
Controller.xibInterface Builder
QuartzFunViewController.xibView
QuartzFunView

UIView

Navigation Bar
Navigation BarNavigation Controller
Navigation Bar
Segmented Control
Navigation Bar

Interface Builder

25

3
4
5
6
7
8

RedBlue
YellowGreenRandomView
12-7
12-7
ControlFiles OwnercolorControl
2Value ChangedFiles Owner
changeColor:
ToolbarToolbar
Delete
Segmented Control
Flexible Space Bar
Button ItemFlexible Space Bar Button
Item

244Line
RectEllipseImageValue ChangedFiles Owner
changeShape:nibXcode

9
10
11
12
13
14
15
16
17

iPhone

18

298

12

Quartz OpenGL

Interface Builder
ToolbarNavigation Bar

Image

12.4.6

XcodeQuartzFunView.mdrawRect:

2.02
UIColorCGColor
currentColor
switchkLineShape

12.4 QuartzFun

299

touchesBegan:

lastTouchlastTouch

2
3
4
5

switch

7
8
9
10
11

Quartz 2DCore Graphics


Core Graphics
Groups & FilesFrameworks
5

Rect Ellipse
Shape
12-8

12.4.7

12
13
14
15

Quartz 2D 12-8
drawRect:

16

17
18

300

12

Quartz OpenGL

currentColor

CGRectcurrentRect
CGRectsizeoriginCGRectMake()xy
widthheightCGRect

12.4 QuartzFun

301

xyxy

CGRect

5
6

7
RectEllipse

12.4.8

12 QuartzFuniphone.png
Resources.png

drawRect:

8
9
10
11
12
13
14
15
16
17
18

302

12

Quartz OpenGL

switchcase kImageShape:GCC
caseGCC
switchhorizontalOffset

lastTouchxyCgpoint

touchesMoved:touchesEnded:QuartzFunView.m

12.4 QuartzFun

303

setNeedsDisplayInRect:
setNeedsDisplayInRect:NSView

1
2
3
4

firstTouchlastTouch
firstTouch

lastTouch
CGRecttouchesBegan:
touchesMoved:touchesEnded:Core
Graphics

drawRect:
3
QuartzFunView.h

6
7
8

9
10
11
12
13
14

15
16
redrawRectCGRect
currentRectdrawRect:

QuartzFunView.m

17
18

304

12

Quartz OpenGL

12.4 QuartzFun

305

1
2
3
4
5
6
7
8

9
10
11
12
13
14

15
16
17
18

306

12

Quartz OpenGL

iPhone

12.5

OpenGL ES

OpenGL ESQuartz 2DOpenGL ES


OpenGL ESQuartz 2D

OpenGL

OpenGLhttp://www.khronos.org/
opengles/OpenGL ES
tutorialhttp://www.khronos.org/developers/resources/opengles/

12.5 OpenGL ES

307

GLFun
XcodeGLFun
Constants.hUIColor-Random.hUIColor-Random.miphone.pngQuartz-Fun
GLFunViewController.h
QuartzFunViewController.h

1
2
3
4
5
6

QuartzFunViewController.m

7
8

9
10
11
12
13
14

15
16
17
18

308

12

Quartz OpenGL

QuartzFunController.mGLFunView
QuartzFunViewUIView

12 GLFun4
Texture2D.hTexture2D.mOpenGLES2DView.hOpenGLES2DView.m
OpenGL ES

OpenGL ESspriteOpenGL ES

Texture2D
OpenGLES2DviewUIViewOpenGL

12.5 OpenGL ES

309

OpenGL ESOpenGL ES
OpenGLES2DviewOpenGL 3-D2-DOpenGL
yyy
OpenGLy
OpenGLES2Dviewdraw

UIViewGLFunView.m
GLFunViewController.xib
12.4.5
XcodeGLFunView.h

1
2
3
4
5
6
7
8

9
10
11
12
13
QuartzFunView.hUIImageTexture2D
OpenGL ESUIViewOpenGLES2Dview
OpenGL ES

14

15

GLFunView.m

16
17
18

310

12

Quartz OpenGL

12.5 OpenGL ES

311

1
2
3
4
5
6
7
8

9
10
11
12
13
14

15
16
17
18

312

12

Quartz OpenGL

12.5 OpenGL ES

313

1
2
3
4
5
6
OpenGLQuartz 2DQuartz
OpenGL
nibinitWithCoder:
UIColorcurrentColoruseRandomColorNO
Texture2D

7
8

OpenGL ES

initWithCoder:draw

10

Quartz

11

12
13
OpenGL

14
15

UIColorRGBOpenGL
UIColorRGBA

16
17
18

314

12

Quartz OpenGL

4
xyQuartzCGPoint struct
OpenGLstruct
OpenGL ES(100, 150)(200, 250)

{x1, y1, x2, y2, x3, y3}CGPoint

glVertexPointer()OpenGL ESOpenGL ES

OpenGL ES

OpenGL3

OpenGLQuartz 2DOpenGL ES
OpenGL ESOpenGLOpenGL ES
OpenGL ES
OpenGLiPhone

Quartz 2D

12.5 OpenGL ES

315

1
2
3
OpenGL ES
currentColor

4
5
6
7

OpenGL ES
720Glfloat360xy
iPhone

firstTouchlastTouch

9
10
11

12
13
14

15
16
17
18

316

12

Quartz OpenGL

OpenGL ESOpenGL ES

4
Texture2DQuartz 2D
draw
drawOpenGL ES

5Core Graphics
OpenGLES.frameworkQuartzCore.frameworkCoreGraphics.framework
OpenGL ESiPhoneOpenGL
EShttp://www.khronos.org/opengles/OpenGL ESOpenGL ES

12.6

OpenGL ESXcode

iPhone OS
OpenGL ES Application

iPhoneQuartz
2D
OpenGL ESiPhone

You might also like