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相机应用程序相同。对我而言,最后一个选择是使用重叠属性来定制每一件事情。如果我可以在不定制的情况下实现此功能,那将会更好。 –