Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Ngay bây giờ, không có bất ngờ với các bạn rằng iPhone có camera tích hợp (mà tiếc là iPod Touch thiếu) và một ứng dụng tiện lợi được gọi là các hình ảnh để giúp bạn quản lý tất cả những hình ảnh tuyệt vời mà bạn đã chụp. | 16 iPhone Camera and Photo Library a y now it should come as no surprise to you that the iPhone has a built-in camera which the iPod Touch unfortunately lacks and a nifty application called Photos to help you manage all those awesome pictures you ve taken. What you may not know is that your programs can use the built-in camera to take pictures and that your programs can also allow the user to select pictures from among the photos already on the iPhone. Because of the way iPhone applications are sandboxed applications ordinarily can t get to photographs or other data that lives outside of their own sand- boxes. Fortunately both the camera and the image library are made available to your application by way of an image picker. As the name implies an image picker is a mechanism that lets you select an image from a specified source. Figure 16-1. An image picker using a list of images left and the camera right Typically an image picker will use a list of images as its source see the picture on the left of Figure 16-1 . You can however specify that the picker use the camera as its source see the picture on the right of Figure 16-1 . 463 464 CHAPTER 16 iPhone Camera and Photo Library Using the Image Picker and UllmagePickerController The image picker interface is implemented by way of a modal controller class called UHmagePickerControll er. You create an instance of this class specify a delegate as if you didn t see that coming specify its image source and then launch it modally.The image picker will then take control of the iPhone to let the user either select a picture from an existing set of images or take a new picture with the camera. Once the user takes or selects the image you can allow an opportunity to do some basic editing such as scaling or cropping on the selected image. Assuming the user doesn t press cancel the image the user takes or selects from the library will be delivered to your delegate. Regardless of whether an image is selected or cancelled your .