Quote:
Originally Posted by Magic Hands
This is what I use, hopefully it helps:
Code:
//--------------------------Handles Picking--------------------------
-(void)openPicker
{
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *picker;
picker = [[UIImagePickerController alloc]init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.allowsImageEditing = YES;
picker.delegate = self;
[self presentModalViewController:picker animated:YES];
}
}
-(void)imagePickerController:(UIImagePickerController *) picker
didFinishPickingImage:(UIImage *)imag
editingInfo:(NSDictionary *)editingInfo
{
someImage = imag;
[someImage retain];
//Call some method here that you want to call after they take the picture
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
}
-(void)imagePickerController:(UIImagePickerController *) picker
{
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
}
-(UIImage*)getTheImage
{
return image;
}
-(void)setTheImage:(UIImage*)img
{
image = [img retain];
}
Good luck!
|
Hi Multi Hands,
I just wanted to draw some more attention to your solution. I have been trying to sort out the use of the UIImagePickerController within my iPhone for about 6 months. I had read probably around 50 posts on the memory issues around this.
I read in lots of places about the app crashing after 5 pictures. However, my app would sometimes work and sometimes crash immediately (switching off the iphone and then back on often helped since it freed up memory).
I found your solution last night and tried it and it worked! I can now carry on with an app that I had stopped developing so thank you VERY much!
I think the fact you increase the referencing count by 1 (using the retain method) is what has fixed my code.
Brilliant and really appreciated,
Charlie