簡體   English   中英

iOS編程。 如何從電話獲取電話簿應用程序的圖片

[英]iOS programming. How to get picture from the phone for a phonebook app

我需要您的幫助/參考/提示,以了解如何從1)iPhone中的我的圖庫和2)從iPhone前置攝像頭中獲取圖片。 這樣我的程序就可以將此圖片復制到iPhone上的本地文件夾中(而不僅僅是引用Gallery)。 謝謝

您可能會發現有關此適當的開發人員文檔的信息很有用。 您可以使用UIImagePickerController從上面的文檔中呈現一個模式視圖,如下面的代碼所示。

- (BOOL) startMediaBrowserFromViewController: (UIViewController*) controller
           usingDelegate: (id <UIImagePickerControllerDelegate,
                               UINavigationControllerDelegate>) delegate {

if (([UIImagePickerController isSourceTypeAvailable:
             UIImagePickerControllerSourceTypeSavedPhotosAlbum] == NO)
        || (delegate == nil)
        || (controller == nil))
    return NO;

UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init];
mediaUI.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

// Displays saved pictures and movies, if both are available, from the
// Camera Roll album.
mediaUI.mediaTypes =
    [UIImagePickerController availableMediaTypesForSourceType:
        UIImagePickerControllerSourceTypeSavedPhotosAlbum];

// Hides the controls for moving & scaling pictures, or for
// trimming movies. To instead show the controls, use YES.
mediaUI.allowsEditing = NO;

mediaUI.delegate = delegate;

[controller presentModalViewController: mediaUI animated: YES];
return YES;                          
}

我確實建議您通讀上面的文檔,因為它非常有用,但不容易解釋。

希望這可以幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM