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