Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Beginning iOS5 Development.pdf
Скачиваний:
7
Добавлен:
09.05.2015
Размер:
15.6 Mб
Скачать

602

CHAPTER 16: Drawing with Quartz and OpenGL

Updating the Nib

We also need to change the view in our nib. Since we copied the QuartzFun project, the view is still configured to use the BIDQuartzFunView for its underlying class, and we need to change that to BIDGLFunView.

Single-click BIDViewController.xib to open Interface Builder. Single-click the Quartz Fun View in the dock, and then press 3 to bring up the identity inspector. Change the class from BIDQuartzFunView to BIDGLFunView.

Finishing GLFun

Before you can compile and run this program, you’ll need to link in two frameworks to your project. Follow the instructions in Chapter 7 for adding the Audio Toolbox framework (in the “Linking in the Audio Toolbox Framework” section), but instead of selecting AudioToolbox.framework, select OpenGLES.framework and QuartzCore.framework.

Frameworks added? Good. Go run your project. It should look just like the Quartz version. You’ve now seen enough OpenGL ES to get you started.

NOTE: If you’re interested in using OpenGL ES in your iPhone applications, you can find the OpenGL ES specification, along with links to books, documentation, and forums where OpenGL ES issues are discussed, at http://www.khronos.org/opengles/. Also, visit

http://www.khronos.org/developers/resources/opengles/, and search for

“tutorial.” And be sure to check out the OpenGL tutorial in Jeff’s iPhone blog, at

http://iphonedevelopment.blogspot.com/2009/05/opengl-es-from-

ground-up-table-of.html.

Drawing to a Close

In this chapter, we’ve really just scratched the surface of the iOS drawing ability. You should feel pretty comfortable with Quartz 2D now, and with some occasional references to Apple’s documentation, you can probably handle most any drawing requirement that comes your way. You should also have a basic understanding of what OpenGL ES is and how it integrates with iOS view system.

Next up? You’re going to learn how to add gestural support to your applications.

www.it-ebooks.info

Chapter17

Taps, Touches, and

Gestures

The screens of the iPhone, iPod touch, and iPad—with their crisp, bright, touchsensitive display—are truly things of beauty and masterpieces of engineering. The multitouch screen common to all iOS devices is one of the key factors in the platform’s tremendous usability. Because the screen can detect multiple touches at the same time and track them independently, applications are able to detect a wide range of gestures, giving the user power that goes beyond the interface.

Suppose you are in the Mail application staring at a long list of junk e-mail that you want to delete. You can tap each one individually, tap the trash icon to delete it, and then wait for the next message to download, deleting each one in turn. This method is best if you want to read each message before you delete it.

Alternatively, from the list of messages, you can tap the Edit button in the upper-right corner, tap each e-mail row to mark it, and then hit the Delete button to delete all marked messages. This method is best if you don’t need to read each message before deleting it. Another alternative is to swipe a message in the list from side to side. That gesture produces a Delete button for that message. Tap the Delete button, and the message is deleted.

This example is just one of the countless gestures that are made possible by the multitouch display. You can pinch your fingers together to zoom out while viewing a picture, or reverse-pinch to zoom in. You can long-press an icon to turn on “jiggly mode,” which allows you to delete applications from your iOS device.

In this chapter, we’re going to look at the underlying architecture that lets you detect gestures. You’ll learn how to detect the most common gestures, and how to create and detect a completely new gesture.

D.Mark et al., Beginning iOS 5 Development

©Dave Mark, Jack Nutting, Jeff LaMarche 2011

www.it-ebooks.info

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]