iPhone如何使用默认UIImagePicker选择最新拍摄的图像



我可以选择显示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;
}

如本问题所示

解决方案包括在选择具有以下行的图像之前增加一个额外的步骤:

imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

这将显示可用照片库的列表,并滚动到所选照片库的底部。

最新更新