如何集成ELCImagePickerController?

时间:2012-04-12 12:26:28

标签: ios ios4 alassetslibrary

我在我的应用程序中使用ELCImagePickerController。根据从Github下载的演示,我使用的代码是

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];

现在它不会起作用,因为ELCImagePickerDemoAppDelegate不是我的应用程序的AppDelegate。那么将这个图像选择器集成到我的应用程序应该是什么正确的代码。 我还尝试将UIViewController子类添加到我的应用程序并调用

[self presentModalViewController:elcPicker animated:YES];

但是这并没有显示选择器并记录消息

deallocing ELCImagePickerController

任何人都可以指导我正确的方向吗?

2 个答案:

答案 0 :(得分:4)

按照以下步骤进行操作

<。>在.h文件中添加此

#import "ELCImagePickerController.h"

并符合ELCImagePickerControllerDelegate协议

并在.m文件中添加此内容

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

并在您要显示选择器的位置添加以下代码

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];

并且还包括所需的协议方法

答案 1 :(得分:0)

尽量不要使用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];