Traditional Culture Encyclopedia - Weather forecast - Content of Crazy iOS Handout (Part II)

Content of Crazy iOS Handout (Part II)

Chapter 1 Multi-touch and gesture detection

1. 1 responder chain2

1.2 Response Touch Method 3

1.3 using the gesture processor (uigesturecognizer) 3

1.3. 1 processing click gesture 4 with UITapGestureRecognizer

1.3.2 Use UIPinchGestureRecognizer to process kneading gesture 6.

Example: Zoom Picture 7 with a pinch gesture

1.3.3 using UIRotationGestureRecognizer to process rotation gesture 9

Example: Rotate Picture 9 by Rotation Gesture

1.3.4 Use UISwipeGestureRecognizer to handle sliding gestures 10

For example: Snake 12

1.3.5 handling drag gestures with uipangesturecognizer18.

1.3.6 Long-press gesture 19 is processed by using UILongPressGestureRecognizer.

Example: Long press the Add button 20.

1.4 Create and use a custom gesture processor 2 1

1.4. 1 Develop a custom gesture processor 2 1

1.4.2 using custom gesture processor 23

1.5 Summary of this chapter 24

Chapter II Internationalization 25

2.1the basis of internationalization of IOs application 26

2.1.1international thinking of IOs application 26

2.1.2 languages and countries supported by objective-c internationalization 28

2.2 International Interface Design Documents 29

2.3 Display name of internationalized application 32

2.4 Internationalized pictures 34

2.5 Internationalized text 35

2.6 Overview of this chapter 38

Chapter 3 Data Storage of iOS and IO39

3. 1 application sandbox 40

3. 1. 1 Get the document directory 4 1

3. 1.2 get the tmp directory 4 1

3. 1.3 Thoughts on file preservation strategy 4 1

3.2 Application Parameters and User Default Settings 42

3.2. 1 Use setting package 42

3.2.2 Reading and saving application parameters with NSUserDefaults 50

3.3 Attribute List 54

For example: memorandum 55

3.4 object archiving and native I/O API58

3.5 using SQLite 3 database 58

3.5. 1 SQLite programming for IOS 58

3.5.2 Creating Databases and Tables 63

3.5.3 Using SQL statements to execute queries 63

Example: English vocabulary book 64

Using sqlite3 tool 67

3.5.5 Using SQLite Manager to Manage Database 69

3.6 Using Core Data Framework71

3. 6. 1 CoreData 7 1 Introduction

3.6.2 Initializing Core Data Item 73

Design the solid model 76

3.6.4 Adding, Deleting, Modifying and Searching Data with Core Data 78

3.6.5 Managing relationships between entities 84

Example: Book Management System 84

3.7 Overview of this chapter 95

Chapter 4 Multimedia Application Development 96

4. 1 Audio and video playback 97

4. 1. 1 Playing sound with system sound service 97

4. 1.2 Play music with audio player 98.

4. 1.3 Use MPMediaPickerController to select system music 102.

Example: Simple Music Player 103

4. 1.4 Playing video with MPMoviePlayerController 106

4.2 recording audio with AVAudioRecorder 108

4.3 Photographing and video recording 1 12

4. 3. 1 use uiimagepickercontroller112 to take photos and record videos.

4.3.2 Take photos and video with AVFoundation 1 16.

Example: fully customized camera 1 18

4.4 using AVFoundation to generate video thumbnails 135

4.5 Overview of this chapter 137

Chapter 5 Managing Mobile Phones 138

5. 1 Manage contacts in the address book 139

5. 1. 1 Delete contact 142

5. 1.2 Add contact 144

5. 1.3 Modify contact person 147

5.2 Manage contacts with AddressBookUI 15 1

5.2. 1 Add contacts with ABNewPersonViewController 153.

5.2.2 Use ABUnknownPersonViewController to display unknown contacts 154.

5.2.3 Select the contact person 156 by using the AbpeoplePickernavigation controller.

5.2.4 Use ABPersonViewController to display the designated contact 157.

5.3 Use UIApplication to make phone calls and send short messages. The number is 159.

5.4 use MFMessageComposeViewController to send SMS 160.

5.5 using MFMailComposeViewController to send mail 162

5.6 Overview of this chapter 165

Chapter 6 Accelerometers and Gyroscopes 166

IOS 167 supported 6. 1 accelerometers and gyroscopes.

6.1.1theoretical basis of IOs accelerometer and gyroscope 167

6. 1.2 Obtain acceleration data, gyro data and magnetic field data according to code block 168.

6. 1.3 Actively request acceleration data, gyro data and magnetic field data 172.

For example: Monster Football 173

6.2 sensor movement 178

Example: Level 18 1

6.3 pedometer 184 has been added in IOs 7.

6.4 CMMOTION activity manager 186 has been added in IOs 7.

6.5 Overview of this chapter 188

Chapter VII Multithreading 189

7. 1 thread overview 190

7. 1. 1 threads and processes 190

7. 1.2 Advantages of multithreading 19 1

7.2 using NSThread to realize multithreading 192

7.2. 1 Create and Start Threads 192

7.2.2 Thread Status 194

7.2.3 Terminate the child thread 194

Thread sleep 195

Example: downloading network picture 196 with thread.

7.2.5 Change thread priority 197

7.3 thread synchronization and thread communication 199

7.3. 1 Line Safety Issues 199

7.3.2 Synchronize with @synchronized 20 1

7.3.3 Release the lock on the synchronization monitor 203.

Synchronous lock (NSLock)203

7.3.5 using NSCondition to control thread communication 205

Example: Producer-Consumer 205

7.4 Using GCD to Realize Multithreading 208

7.4. 1 Create Queue 209

7.4.2 Asynchronous submission of task 2 10

Example: download picture 2 12 with GCD.

7.4.3 Submit Task 2 13 synchronously

7.4.4 Repeated Tasks 2 14

7.4.5 Tasks that can only be executed once 2 15

7.5 background running 2 16

7.5. 1 Release memory when entering the background 2 16

Example: Crazy Plane Wars 2 16

7.5.2 Save the status when entering the background 223

7.5.3 Request more background time 223

7.6 Using NSOperation and NSOperationQueue to Realize Multithreading 225

7.6. 1 use NSInvocationOperation and NSBlockOperation226.

Example: downloading pictures 226 using NSBlockOperation

7.6.2 Define NSOperation subclass 227.

7.7 Overview of this chapter 229

Chapter 8 iOS network application programming 230

8. 1 detect network status 23 1

8. 1. 1 Check the network status 23 1

8. 1.2 monitoring network state change 234

8.2 using CFNetwork to realize the communication of TCP protocol 235

8.2. 1IP address and port number 236

8.2.2TCP Protocol Basis 236

8.2.3 Implementation of TCP Server 237 with CFSocket

8.2.4 Implementation of TCP Client 24 1

Example: Web Chat Program 244

8.2.5 Implementing TCP Client 247 with CocoaAsyncSocket

8.3 using NSURLConnection 250

8.3. 1 use NSURLConnection to get data from the network 250

8.3.2 send data to the server using NSMutableURLRequest 253.

8.4XML parsing 255

8.4. 1DOM and SAX 255

8.4.2 parsing XML document 257 using NSXMLParser

8.4.3 parsing XML document 262 with libxml2

8.4.4 Parsing XML document 266 by using GDataXML.

8.4.5 Generate and modify XML documents 268 using GDataXML.

8.5JSON parsing 27 1

8. 5. 1 JSON basics 27 1

8.5.2 Using NSJSONSerialization to process JSON data274

8.5.3 parsing JSON data using SBJson 274.

8.5.4 parsing JSON data with JSONKit 275

8.6 using AFNetworking to realize network communication 280

8.6. 1 Submit GET request and submit POST request 280

Example: Access to Protected Resource281

8.6.2 Handling JSON or Plist Response 284

8.6.3 Processing XML Response 288

Upload file 290

8.7 Using ASIHTTPRequest Framework to Realize Network Programming 293

Send synchronous or asynchronous GET request 293

8.7.2 Using Code Block 296

8.7.3 Using NSOperationQueue to Manage Requests 297

8.7.4 Send request parameters and file upload 299

For example: weather forecast 300

8.8 Summary of this chapter 3 1 1

Chapter 9 uses CoreLocation to locate 3 12.

9. 1iOS location support 3 13.

9. 1. 1GPS satellite positioning 3 13

9. 1.2 base station positioning 3 14

9. 1.3WiFi location 3 14

9.2 Getting Location Information 3 14

9.2. 1 obtaining location information 3 15

9.2.2 Simulate the position of 3 18 with an iOS simulator.

9.2.3 Monitoring driving speed and driving distance 3 18

9.3 Direction Monitoring 320

Example: Compass 322

9.4 Regional monitoring 323

9.5 Overview of this chapter 325

Chapter 10 Using MapKit to Develop Map Service 326

10. 1 using MapKit framework 327.

10. 1. 1 using MKMapView control 328

10. 1.2 specifies the map display center and display area 329.

10. 1.3 Use MKMapCamera 332 added by iOS 7.

10.2 by address location 333

10.2. 1 address resolution and reverse address resolution 333

10.2.2 is located by address 337.

10.3 Add anchor point 340 on the map.

10.3. 1 Add a simple anchor point 340.

10.3.2 Add custom anchor point 343

10.4 Add overlay 345 on the map.

10.4. 1 Add geometric overlay 346.

10.4.2 use MKTileOverlay 348 added by iOS 7.

10.5 Use MKDirections added in iOS 7 to obtain navigation route 350.

Example: Driving Navigator 35 1

10.6 Summary of this chapter 354

Chapter 1 1 Promotion mechanism 355

1 1. 1 Communication with NSNotificationCenter 356

11.1.1Notice of using NSNotificationCenter monitoring system components 358

1 1. 1.2 Monitoring custom notifications using NSNotificationCenter 359

1 1.2 operating system local notification 36 1

1 1.3 operating system remote push notification 364

1 1.3. 1 develop push client App366.

1 1.3.2 developing push server program 377

1 1.4 Abstract of this chapter 38 1

Chapter 12 iCloud services and applications 382

Introduction to 12. 1 I cloud 383

12. 1. 1 Open iCloud service for App384.

12.10.2 using NSMetadataQuery to query document 389

12. 1.3 Add Document 393

12. 1.4 Edit the document 395

Delete file 397

12.2 use iCloud 398 to store cloud preferences.

12.3 Abstract of this chapter 40 1

Chapter 13 Developing 2D Games with cocos2d 402

Introduction to 13. 1cocos2d 403

Features of13.1.1cocos2d: 20000.000000000105

Main functions of 13. 1.2cocos2d 403

13.2 download and install cocos2d 404.

13.2. 1 download cocos2d 404.

13.2.2 install cocos2d405.

13.2.3 using the help document of cocos2d-iPhone 405.

Item 406 manufactured in 13. 2. 4 cocos 2d

13.3 create cocos2d project 407

13.3.1helloworld cocos2d project 407

13.3.2 Does COCOS2D COCOS2D project support ARC 408?

13.3.3cocos2d project structure and code analysis 4 13

13.4 cnode node class419

13. 4. 1cc node class attribute 4 19

13. 4. 2 code class 420.

13.5 cc scene scene class 423

13.5.1cctransition scene scene switching 423

COCOS2D transition effect supported by 13. 5. 2 cocos2d 424

13.6 cc layer 424

13. 6. 1cc clayer property of class 425.

13.6.2 Common Methods of Clayer Class 425

13.6.3 the role of Clayer class 425

Properties and methods of13.6.4 cclayercolor class 425

13. 6. 5 cc layer gradient layer category 426

13. 6. 6 cc menu menu category 426

13.7CCDirector class 429

13. 7. 1cc director class 430 properties.

13. 7. 2 Method for Commanders to Command Classes 430

13.8ccture texture class431

13. 8. 1 related concepts

13.8.2 texture related class 43 1

13.9CCSprite level 432

13.9.1ccsprite elf class 432 properties.

13. 9. 2 csprite elf class 432 method.

13.9.3 cspritframe wizard framework 435

13.9.4csppriteframecache wizard frame buffer 436

13.9.5CCSpriteBatchNode wizard form 436

13.9.6 Making Wizard Form 438

13.9.7 Wizard Form Example 440

Operation 442 in 13. 10cocos2d

Operation classes in13.10.1cocos2d443

Basic action 444

13. 10.3 comprehensive action 453

13. 10.4 Easy operation 454

13. 10.5 delay action 456

13. 10.6 method callback operation 456

13. 10.7 code block calls operation 460.

13. 1 1 animation in COCOS2D 462

13.11.1cocos2d animation related class 462

13. 1 1.2 Simple animation effect4663

13. 165438+

Text in 13. 12cocos2d 466

13. 12. 1 cclabeltf class 466

13.12.2 cclabelmfont class 467

13.13 the voice in cocos2d470.

13. 13. 1 simple audio engine 470

13. 13.2 Function realization of sound setting options in game 474

13. 14 Crazy masturbation game 477

Preparation before 13. 14. 15 36438

13. 14.2 add the function of game menu item 478.

13. 14.3 Pre-installed game resources 480

Player's Flying Effect 485

13. 14.5 player's plane touch realization 487

Background scrolling effect 488

13. 14.7 Add enemy plane 49 1

13. 14.8 player's plane is loaded with bullets.

Add background music 498

13. 14. 10 Add game score statistics 498

13.14.11add game Boss 500.

Overview of this chapter 504

Chapter 65438 +04 Particle Effect, Tile Mapping and Physics Engine 505

Class 506 related to 14. 1 particle system

14. 1. 1 cc particle system class 506

14. 1.2 ccparticlesystemquad class 5 1 1

14.1.3 ccparticlebachnode class 5 12

Particle system built in 14.2 COCOS2D 5 12

14.2. 1 use the particle system built in cocos2d 5 13.

14.2.2 Manually create a particle system class 5 14

14.3 using particle designer to generate particle effects 5 17

Using Particle Designer Particle Tool 5 18

14.3.2 Create particle system using plist file 520

14.4 Tile map 520

14. 4. 1 Download and install the Slice Map Editor 52 1.

14.4.2 Use tiling to draw a map 522

14.5 Detailed map related classes 527

14.5.1cctmxtilemap class 527

14.5.2 ctmxlayer level 529

14. 5. 3 ctmxobjectgroup class 530

14.6 using tiled map 530 in the project

14.7 Real Mobile Tour: Dream Fairy 535

1 Design map scene 535

Load map 535

Map movement 537

14.7.4 Occlusion effect of objects 539

14.7.5 Set up obstacles.

14.7.6 pathfinding algorithm 544

14.7.7 Monster 549 appears randomly.

14.7.8 Players and monsters fight 552

14.8Box2D physical engine 559

14.8. 1 physical engine overview 559

The core concept of 14. 8. 2 box 2d 559

General properties and methods of 14. 8. 3 box2d box2d 562

14.8.4Box2D template project HelloBox2D 563

14.8.5HelloBox2D template project code analysis 565

14.8.6cocos2d and Box2D 573

14.8.7Box2D development step 575

14.9 development Box2D project 575

Angry Birds 58 1

Preparation before starting 58 1

14. 10.2 Making the game start screen 58 1

14. 10.3 progress bar making 582

14. 10.4 particle effects in the game 585

14. 10.5 Game Gating Operation 590

14. 10.6 design level data 594

Design Wizard Class 596

14. 10.8 game main interface 60 1

14. 10.9 Slingshot to launch birdie 604

14. 10. 10 integrated Box2D physical engine 609

14.10.11game pass design 6 13

14. 1 1 abstract of this chapter 6 16