UIImagePickerController(二)

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:
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容