Picking an Item from the Photo Library
UIImagePickerController的功能:
1.image picker功能主要有兩個:一個是捕獲picture和medias;一個是彈出一個瀏覽頁,選擇一個item
In addition to using a UIImagePickerController instance to capture new pictures and movies, you can use it to present a media browser that lets a user choose an item from their saved photo albums. The steps you take are similar to those for capturing media, as described in Taking Pictures and Movies. The differences are:
- sourceType
- take a picture or movie and save its. present a browser and display its.
Creating and Configuring a Media Browser
- 條件測試(condition test)
UIRequiredDeviceCapabilities info.plist
isSourceTypeAvailable:
-
實例化(instantiate)
UIImagePickerController *cameraUI [[UIImagePickerController alloc] init];
-
配置(configure)
-
sourceType
UIImagePickerControllerSourceTypePhotoLibrary 可以訪問設(shè)備的所有相冊集,包括有攝像機的設(shè)備的相機膠卷
UIImagePickerControllerSourceTypeSavedPhotosAlbum 限制范圍:帶有攝像頭的設(shè)備的相機膠卷,或沒有帶有攝像頭的設(shè)備的相冊。
mediaType
check which media types are available by calling the availableMediaTypesForSourceType:,給mediaType設(shè)置一個空數(shù)組會throw an exception.allowsEditing
you can custom UI, for example, specify custom cropping.delegate
-
-
彈出(present)
iPhone, iPod touch full-screen present
-
iPad
iOS ...-9.0 UIPopoverController
iOS 9.0-later UIPopoverPresentationController
-
處理代理方法(conform delegate method)
- imagePickerController:didFinishPickingMediaWithInfo: