tags:

views:

257

answers:

1

Hi,

In my app, I have two view controllers. The MainViewController switches to the AlbumViewController when a button is pressed. The AlbumVC is supposed to allow the user to select a picture from the PhotoLibrary and/or CameraRoll. So, I try to fire up the UIImagePickerController.

However, when the app runs, I don't see the UIImagePickerController at all. Not compiler errors and no run time errors.

Can some kind soul help me!

Here is the source..... Sam

MainViewController.h

    #import <UIKit/UIKit.h>

    @interface iNotateViewController : UIViewController {

    }

@end

MainViewController.m

#import "iNotateViewController.h"

@implementation iNotateViewController

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}


- (void)dealloc {
    [super dealloc];
}

@end

AlbumViewController.h

#import <UIKit/UIKit.h>
#import <UIKit/UIViewController.h>

@interface AlbumViewController : UIViewController <UINavigationControllerDelegate,
                UIImagePickerControllerDelegate >{

}
@end

AlbumViewController.m

    - (void)viewDidLoad {

        [super viewDidLoad];

        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
         UIImagePickerController *picker;
         picker = [[UIImagePickerController alloc] init];
         picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
         picker.allowsImageEditing = YES;

         picker.delegate = self;

         [self presentModalViewController:picker animated:YES];

         [picker release];  
        }
    }


    -(void)imagePickerController: (UIImagePickerController *) picker
           didFinishPickingImage: (UIImage *) image
            editingInfo: (NSDictionary *) editingInfo {
        [self useImage:image];
        [[picker parentViewController] dismissModalViewControllerAnimated:YES];
    }

    -(void)imagePickerControllerDidCancel: (UIImagePickerController *)picker {
        [[picker parentViewController] dismissModalViewControllerAnimated:YES];
    }
@end
A: 

I believe you should move [picker release] to the dealloc method

ennuikiller
Thanks for the idea....I made the 'picker' an instance variable, and moved the [picker release] to the dealloc: method. I still don't see the picker controller. In fact, the delegate method didFinishPickingImage: is not being called. I set a breakpoint there, and it's not hit.Hope this sheds more light on the problem.....
No One?? Please help!!!