2
我們如何顯示相機和視頻模式下的UiImagepicker控制器界面,以及與iPhone的默認相機應用程序相同的Photo Library圖標按鈕。使用UIImagePickerController顯示相同的默認相機應用程序
或如何刪除取消按鈕(顯示在相機視圖中)並用不同的按鈕替換。是否有可能,蘋果是否會批准這種方法。
請幫我一下嗎?
我們如何顯示相機和視頻模式下的UiImagepicker控制器界面,以及與iPhone的默認相機應用程序相同的Photo Library圖標按鈕。使用UIImagePickerController顯示相同的默認相機應用程序
或如何刪除取消按鈕(顯示在相機視圖中)並用不同的按鈕替換。是否有可能,蘋果是否會批准這種方法。
請幫我一下嗎?
你可以試試這種方式。
BOOL hasCamera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
if(hasCamera){
UIActionSheet *actionSheet;
actionSheet = [[[UIActionSheet alloc] initWithTitle:@"Add Photo"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Select from Library", @"Take a New Photo", nil] autorelease];
actionSheet.actionSheetStyle = UIBarStyleBlackOpaque;
[actionSheet showInView:[self view]];
}
else {
UIImagePickerController* imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.allowsEditing = YES;
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:imagePickerController animated:YES];
[imagePickerController release];
}
Actionsheet委託方法
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
//BOOL hasCamera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
UIImagePickerController* imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.allowsEditing = YES;
imagePickerController.delegate = self;
if(buttonIndex == 0)
{
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
else if(buttonIndex == 1)
{
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
}
[self presentModalViewController:imagePickerController animated:YES];
[imagePickerController release];
}
圖像拾取委託
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
if(image)
{
[self.addPhotoButton setBackgroundImage:image forState:UIControlStateNormal];
}
[picker dismissModalViewControllerAnimated:YES];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[picker dismissModalViewControllerAnimated:YES];
}
- 我想表明在相機屏幕只有照片庫中選擇用戶。與默認iPhone相機應用程序相同。對我而言,最後一個選擇是使用重疊屬性來定製每一件事情。如果我可以在不定製的情況下實現此功能,那將會更好。 –