How to add UIImagePickerController to UiView

How to add UIImagePickerController to UiView in TabBarApplication

+3
source share
1 answer

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

Create a collector if you want it

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

Add Collector

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

Your view controller must be declared as

@interface YourViewController :  
   UIViewController<UIImagePickerControllerDelegate, UINavigationControllerDelegate>

And you need to implement

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

(the first is to get the image from the information object)

In each of these messages, when this is done, remove the collector

[self dismissModalViewControllerAnimated:YES];
+15
source

Source: https://habr.com/ru/post/1716751/


All Articles