How to add UIImagePickerController in UiView

ε祈祈猫儿з 提交于 2019-12-07 12:50:09

问题


How to add UIImagePickerController in UiView in TabBarApplication


回答1:


It doesn't matter if you are in a tab, this code goes into the ViewController class for your view

Create a picker when you want one

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
// configure it how you want

Add the picker

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

Your view controller needs to be declared like

@interface YourViewController :  
   UIViewController<UIImagePickerControllerDelegate, UINavigationControllerDelegate>

And you need to implement

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

(the first one should get the image from the info object)

In each of those messages, when done, remove the picker

[self dismissModalViewControllerAnimated:YES];


来源:https://stackoverflow.com/questions/1371446/how-to-add-uiimagepickercontroller-in-uiview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!