如何在UiView中添加UIImagePickerController

时间:2009-09-03 04:29:02

标签: iphone ios uiimagepickercontroller

如何在TabBarApplication中的UiView中添加UIImagePickerController

1 个答案:

答案 0 :(得分:15)

如果你在一个标签中没关系,这段代码会进入你视图的ViewController类

当您想要一个

时创建一个选择器
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
// configure it how you want

添加选择器

[self presentViewController:picker animated:YES completion:nil];

您的视图控制器需要声明为

@interface YourViewController :  
   UIViewController<UIImagePickerControllerDelegate, UINavigationControllerDelegate>

你需要实施

- (void)imagePickerController:(UIImagePickerController *)picker 
    didFinishPickingMediaWithInfo:(NSDictionary *)info;
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker;

(第一个应该从info对象获取图像)

在每条消息中,完成后,删除选择器

[self dismissModalViewControllerAnimated:YES];