Reputation:
How to add UIImagePickerController in UiView in TabBarApplication
Upvotes: 3
Views: 4399
Reputation: 89242
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];
Upvotes: 15