0
我正在寻找允许用户从相机视图访问图库的方式。如何从相机视图访问图库?
默认情况下,一个具有明确设置源类型UIImagePickerController
self.myPickerController.sourceType = UIImagePickerControllerSourceType.camera
有没有什么办法让它在路上像机iOS相机应用?注意微小的画面中左下角
我正在寻找允许用户从相机视图访问图库的方式。如何从相机视图访问图库?
默认情况下,一个具有明确设置源类型UIImagePickerController
self.myPickerController.sourceType = UIImagePickerControllerSourceType.camera
有没有什么办法让它在路上像机iOS相机应用?注意微小的画面中左下角
你就可以有呈现给用户两种选择,并允许他们从相册选择照片或用相机
if (optionId == 1) {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, kUTTypeImage, nil];
imagePicker.allowsEditing = NO;
imagePicker.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:imagePicker animated:YES completion:nil];
}else {
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:[NSString stringWithFormat:@"Camera not supported."] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alertView show];
}
}else if (optionId == 2) {
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]) {
imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
} else {
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
imagePicker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, kUTTypeImage, nil];
imagePicker.allowsEditing = NO;
imagePicker.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:imagePicker animated:YES completion:nil];
}
我不认为有任何选择,你需要给两个不同的源类型 – guru