aQb Solutions
aQb Solutions

Reputation: 109

How to integrate ELCImagePickerController?

I am using ELCImagePickerController in my app. According to the demo downloaded from Github the code I have used is

ELCAlbumPickerController *albumController = [[ELCAlbumPickerController alloc]    initWithNibName:@"ELCAlbumPickerController" bundle:[NSBundle mainBundle]];    

ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] initWithRootViewController:albumController];

[albumController setParent:elcPicker];

[elcPicker setDelegate:self];

ELCImagePickerDemoAppDelegate *app = (ELCImagePickerDemoAppDelegate *)[[UIApplication sharedApplication] delegate];

[app.viewController presentModalViewController:elcPicker animated:YES];

[elcPicker release];
[albumController release];

Now it is not going to work as ELCImagePickerDemoAppDelegate is not the AppDelegate of my application.So what should be the correct code to integrate this image picker to my app. I also tried adding a UIViewController subclass to my app and calling

[self presentModalViewController:elcPicker animated:YES];

But that does not show the picker and logs a message

deallocing ELCImagePickerController

Can anyone guide me to right direction ?

Upvotes: 2

Views: 3080

Answers (2)

Cameron E
Cameron E

Reputation: 1869

Try not using initWithNibName...

#import "ELCImagePickerController.h"
#import "ELCAlbumPickerController.h"

ELCAlbumPickerController *albumController = [[ELCAlbumPickerController alloc] init];
    ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] initWithRootViewController:albumController];
[albumController setParent:elcPicker];
    [elcPicker setDelegate:self];
    [self presentModalViewController:elcPicker animated:YES];

Upvotes: 0

The iOSDev
The iOSDev

Reputation: 5267

just do as follow

in .h file add this

#import "ELCImagePickerController.h"

and conforms to ELCImagePickerControllerDelegate protocol

and in .m file add this at top

#import "ELCImagePickerController.h"
#import "ELCAlbumPickerController.h"

and add following code where you want to show the picker

ELCAlbumPickerController *albumController = [[ELCAlbumPickerController alloc] initWithNibName:@"ELCAlbumPickerController" bundle:[NSBundle mainBundle]];    
    ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] initWithRootViewController:albumController];
    [albumController setParent:elcPicker];
    [elcPicker setDelegate:self];
    [self presentModalViewController:elcPicker animated:YES];

and also include the required protocol methods

Upvotes: 4

Related Questions