3

如何在 TabBarApplication 的 UiView 中添加 UIImagePickerController

4

1 回答 1

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];
于 2011-02-05T20:21:28.313 回答