2012-07-24 30 views
2

我有一個選項來顯示UIImagePicker並從用戶的相機膠捲中選擇一個圖像在我的應用程序中。我遇到的問題是照片按最舊的頂部排序。這可以輕鬆挑選幾個月前拍攝的圖像。我希望用戶快速選擇幾分鐘前拍攝的圖像,而不必滾動到列表的末尾(列表底部)。iPhone如何使用默認的UIImagePicker選擇最新拍攝的圖像

有沒有要求默認的UIImagePicker排序其結果並顯示最新的或至少滾動到列表的末尾後提交?

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

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


    UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init]; 
    cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera; 

    // Displays a control that allows the user to choose picture or 
    // movie capture, if both are available: 
    cameraUI.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage]; 

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

    cameraUI.delegate = delegate; 
    [controller presentModalViewController: cameraUI animated: YES]; 
    return YES; 
} 
+1

Duplicate:http://stackoverflow.com/questions/3947157/uiimagepickercontroller-is-it-possible-to-change-the-sort-order-of-the-images-i – 2012-07-24 20:12:07

回答

2

如在本This question

指示的解決方案涉及用線選擇圖像之前加入一個額外的步驟:

imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 

這顯示可用照片庫和滾動到列表所選一個的底部。

相關問題