我正在开发一款允许用户上传图片的应用。从库中选择图像时,我希望它最初加载相机胶卷(已保存的照片),同时还提供“后退”按钮以访问其照片库 strong>(即其他专辑)。
这是我的代码:
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.delegate = self;
imagePicker.allowsEditing = NO;
[self presentModalViewController:imagePicker animated:YES];
}
else {
UIAlertView *alert;
alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"This device doesn't support photo libraries."
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
}
这将从完整的照片库屏幕开始,该屏幕允许用户从任何相册中选择任何图像,但需要再点击一次才能进入相机胶卷,然后再转到下一个上传屏幕。
如果我切换 - imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
,那么它会在相机胶卷中开始,但不允许访问其他相册。
有什么想法吗?谢谢!