iOS 7 Development Recipes A Problem-Solution Approach

所需积分/C币:10 2014-09-01 08:27:07 22.32MB PDF
0
收藏 收藏
举报

iOS 7 Development Recipes A Problem-Solution Approach英文原版
Contents at a Glance About the authors About the technical reviewer ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ Acknowledgments wXX Introduction m XXv Chapter 1: Application Recipes ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ Chapter 2: Storyboard recipes mBBBBBIBRIRREIRRIR n 59 Chapter 3: Layout Recipes aad ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■国■■ 93 Chapter4: Table and co‖ lectionⅥ ew Recipes,,,,,,,,,,,,,,…,135 Chapter 5: Location Recipes n199 Chapter 6: Motion Recipes aama IRRaEIRIIRIIRRIRI 241 Chapter 7: Map recipes.mmmmmmmmmmmmmmmmmmmm 273 Chapter 8: Social Network Recipes 343 Chapter 9: Camera Recipes 367 Chapter 10: Multimedia Recipes mam 439 Chapter 11: Image Recipesmmmm RR AMRaam Iaa 477 Chapter 12: Graphics Recipes 511 Chapter 13: Animation and Physics Recipes ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■口■■■■ 537 Contents at a glance Chapter 14: User Data Recipes ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■ 571 Chapter 15: Data Storage Recipes ■■■■■ 623 Chapter 16: Data transmission Recipes RRa ■■■■■■■ ■■■■■■ 679 Chapter 17: Game Kit Recipes ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 711 Index ■■■■■■ ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■I 767 Introduction The easy part of software development is knowing how to write code in the programming language at hand. The tougher part is mastering the programming interfaces of the platform and getting to the level where you can effectively turn ideas into working features with real values. iOS 7, although extremely powerful and easy to use, is no exception to this. Objective-C, considered by many to be a somewhat"funky "programming language, is a language you can get your head around quickly and even learn to appreciate. However, you're likely to spend a lot of time learning the various aPls and frameworks We believe the best way to acquire the necessary knowledge and reach a plateau of high productivity is through hands-on experience. We think the best way to learn is to follow step-by-step procedures, creating small projects in which you can test and tweak the features and get a feel for them before you implement them in your real projects With this idea in mind, we created ioS 7 Development Recipes. This book contains over 600 pages of sample code accompanied by instructions about how to create small test apps that allow you to run the code on your ios 7 device or in the iOS simulator le have tried to cover as many topics as possible based on the features of ioS 7. We hope this book provides the fundamentals you need to start converting your great ideas into fantastic apps Who this book s for When you read this book it will help if you have a basic knowledge of objective-C, have taken your first steps in Xcode, and have written a couple of Hello World apps. If you haven't, don't worry; simply pay extra attention to the first eight recipes of Chapter 1. They should provide most of the basics you will need in order to follow along with the recipes in the rest of the book ovi Introduction How this book is structured For the most part, the example-based chapters of this book do not build on one another; that is you do not have to read the chapters sequentially. You should be able to read the chapters and build your apps in any order you want, depending on your specific interests. Whenever we do build on an example from a different chapter, we will let you know However, we recommend that you at least skim Chapter 1, Application Recipes, then Chapter 2 Storyboard Recipes, " and finally Chapter 3, Layout Recipes, before moving on The first chapter contains recipes for common tasks, such as creating outlets and actions, which are referenced throughout the book and should be fully understood before you move ahead The second chapter covers storyboards. Storyboards are an alternative way of building user interfaces. Storyboards show both the individual screens(single view controllers and the connections(segues) between them. Before the introduction of storyboards in iOS 5, xib files were typically used to build the interface. The xib files were individual scenes; that is, one. xib file per scene. The connections between xib files were handled in code. While you still have the ability to use xib files, it is clear that Apple is pushing developers more and more to use storyboards instead The third chapter provides basic knowledge of the layout tools for ioS 7. Reading that chapter might be helpful when you create the user interfaces of the recipes later, especially if you want your scenes to look good on multiple devices This book uses a mix of programmatic interface building, storyboards, and xib files. For the most part, you will start every application with a single view application template for the iPhone that will include a storyboard. We will instruct you otherwise if this is not the case Throughout this book, we assume you are developing in the latest versions of iOS and Xcode, which at the time of writing are ioS 7.0 and Xcode 5.0 Many of the recipes in this book cannot be fully tested on the ios simulator, and as such will require both an ios device and a provisioning profile, which you can acquire when you subscribe to the ios Developer Program. At the time of this writing, the developer program costs $99.00 USD. We've pointed out each recipe that cannot be tested in the ioS simulator Note Since the introduction of iphone 5 there are two screen sizes to account for the 3.5"screen and the 4"screen the width in both screens is the same but the 4"screen is taller most of the interfaces in this book are laid out to look good on a 3. 5"screen and will have unused space if run on a 4 screen. Feel free to modify the interface to better fit a 4 screen if that is what you want. chapter 3 discusses auto layout, which will give you the tools to make an interface look good on either size screen Introduction xxvii What's new in this edition By now you undoubtedly have seen the fresh look of iOS 7. Because of the new software, we've made numerous changes to the images and code we provided in the previous edition of this book joS 6 Recipes: A Problem-Solution Approach. While we couldn't address everything ios 7 has to offer in this new edition, we tried to add some topics we found very useful to the average developer Because ioS 7 is a major overhaul in design, all the images and figures have been updated to reflect the new design. Apple has made numerous minor changes to existing aPls for ioS 7. We updated the code in this book to reflect those changes advantage of storyboards rather than xib files Previous editions of this book were largely based e Due to Apple's added emphasis on storyboards, we have changed the examples in this book to take onxib files. In addition, we created a new chapter for storyboards(Chapter 2), which now includes instructions for creating tab view controllers Auto Layout has changed with ioS 7, so we have updated chapter 3 to reflect these changes Auto Layout constraints no longer exist for the developer. This greatly increases developer freedom and flexibility Apple added nice features to the Map Kit framework, which allow you to get directions from Apple as well as take full advantage of 3-D map support. We have included recipes that show you how to use both of these new features in chapter 7 ios 7 gives us the ability to detect and read QR codes with the camera natively. We added a new recipe to Chapter 9, "Camera Recipes, that shows how to read QR codes We also added Chapter 12, which focuses on Core Graphics. While the previous edition touched on Core Graphics, We have expanded the content in its own chapter. The most exciting contribution to this new edition is a new chapter on animation( Chapter 13) This chapter introduces some UIView animation basics and then moves on to the new UIKit Dynamics framework. This framework allows for realistic, physics-inspired animation Downloading the code ThecodefortheexamplesincludedinthisbookisavailableontheApresswebsiteatwww.apress.com You can find a link on the book's information page under the Source Code/Downloads tab. This tab is located under the related Titles section of the page Contacting the Author If you have any questions or comments regarding this book, I would be happy to hear them contact meatNSCookbook@gmail.comandinclude"iOS7Recipes"inthesubjectline,orwriteacommenton myblogathttp://www.NscoOkbOok.com Chapter Application Recipes This chapter serves as both a refresher for creating apps for ios and a foundation for completing the basic tasks that are repeated throughout this book. The first eight recipes walk you through fundamental tasks such as setting up an application, connecting and referencing user interface elements in your code, and adding images and sound files to your project. The knowledge you will acquire from the recipes in this chapter is necessary to complete many of the tasks in the other chapters of this book The last four recipes in this chapter deal with select, useful tasks such as setting up simple aPls for default error and exception handling, including a lite"version of your app in your projects, and making an app launch seem quick and easy in the eyes of the user. For the most part, these tasks won't be repeated in the remainder of this book; however, we feel they are essential knowledge for any developer. Recipe 1-1: Setting Up a Single view Application Many of the recipes in this book are implemented in a test application with a single view. Such a project is easy to set up in Xcode using the Single View Application template. This template enables you to use storyboards. A storyboard is a way to build interfaces consisting of multiple scenes and their connections Before the introduction of storyboards in iOs 5,. xib files were typically used to build the interface for individual scenes; in other words, there was one xib file per scene. The connections between xib files were handled in code. While you still have the ability to use xib files, Apple is pushing developers to use storyboards instead. As such, you will be using storyboards for most of this book To create a new single view application, go to the main menu and select File New >Project. This brings up the dialog box with available project templates(see Figure 1-1). The template you want is located on the Application page under the iOS section. Choose"Single View Application" and cick“Next CHAPTER 1: Application Recipes Choose a template for your new project Framework Library Other Master-Detail OpengL Game Page-Based Single View os某 Application Application Application Application Framework Library Application Plug-in 重 System Plug-in Other Tabbed Application Utility Application Empty Application Spritekit Game Single view Application This template provides a starting point for an application that uses a single view. It provides a view controller to manage the view, and a storyboard or nib file that contains the view Cancel Previous Next Figure 1-1. The single view application template in the ios application section Enter a few properties for your Application recipes A Product Name, such as My Test App An Organization Name, which can be your name, unless you already have an organization name A Company Identifier, which preferably is your Internet domain, if you have one If you like, you can also enter a class prefix that will be applied to all classes you create using the Objective-C file template. This can be a good idea if you want to avoid future name conflicts with third-party code; however, if this app is meant only for testing a feature, you can leave the class prefix item blank You also need to specify which device type your application is for: iPad, iPhone, or both Universal Choose iPhone or iPad if you are testing. You can also pick Universal, but then the template will generate more code, which you probably don 't need if your only purpose is trying a new feature Figure 1-2 shows the properties you need to fill out in the project options window CHAPTER 1: Application Recipes Choose options for your new project: Product Name My SIngle View App Organization Name NSCookbook Company Identifier NSCookbook Bundle Identifier NSCookbook My-Slngle-View-App Class PrefixXYZ Devices iPhone APPRCATIN, APT Cancel PreviousNext Figure 1-2. Configuring the project Click the "Next"button and then select a folder where the project will be stored. Bear in mind that Xcode creates a new folder for the project within the folder you pick, so select the root folder for your projects. There's often a good reason to place the project under version control. It allows you to check changes to the code so you can go back to a previous version if something goes wrong or if you simply want to see the history of changes to the application. Xcode comes with Git, a feature-rich open-source version-control system that allows multiple developers to work on a project simultaneously with ease. To initialize it for your project, check the Create local git repository for this project "checkbox, as in Figure 1-3. As of Xcode 5, you can specify a server as well as your mac for this repository

...展开详情
试读 127P iOS 7 Development Recipes A Problem-Solution Approach
立即下载 低至0.43元/次 身份认证VIP会员低至7折
抢沙发
一个资源只可评论一次,评论内容不能少于5个字
上传资源赚积分or赚钱
    最新推荐
    iOS 7 Development Recipes A Problem-Solution Approach 10积分/C币 立即下载
    1/127
    iOS 7 Development Recipes A Problem-Solution Approach第1页
    iOS 7 Development Recipes A Problem-Solution Approach第2页
    iOS 7 Development Recipes A Problem-Solution Approach第3页
    iOS 7 Development Recipes A Problem-Solution Approach第4页
    iOS 7 Development Recipes A Problem-Solution Approach第5页
    iOS 7 Development Recipes A Problem-Solution Approach第6页
    iOS 7 Development Recipes A Problem-Solution Approach第7页
    iOS 7 Development Recipes A Problem-Solution Approach第8页
    iOS 7 Development Recipes A Problem-Solution Approach第9页
    iOS 7 Development Recipes A Problem-Solution Approach第10页
    iOS 7 Development Recipes A Problem-Solution Approach第11页
    iOS 7 Development Recipes A Problem-Solution Approach第12页
    iOS 7 Development Recipes A Problem-Solution Approach第13页
    iOS 7 Development Recipes A Problem-Solution Approach第14页
    iOS 7 Development Recipes A Problem-Solution Approach第15页
    iOS 7 Development Recipes A Problem-Solution Approach第16页
    iOS 7 Development Recipes A Problem-Solution Approach第17页
    iOS 7 Development Recipes A Problem-Solution Approach第18页
    iOS 7 Development Recipes A Problem-Solution Approach第19页
    iOS 7 Development Recipes A Problem-Solution Approach第20页

    试读结束, 可继续阅读

    10积分/C币 立即下载 >