我在按钮单击时打开相机并在 uiimage 中拍摄图像,然后将该 uiimage 传输到其他视图但是当我这样做 4-5 次时收到内存警告。
以下是我工作的代码:-
-(void)imagePickerController:(UIImagePickerController*)picker_camera didFinishPickingMediaWithInfo:(NSDictionary*)info
{
[picker_camera dismissModalViewControllerAnimated:YES];
UIImage *image=[[UIImage alloc] init];
image=[info objectForKey:@"UIImagePickerControllerOriginalImage"];
[self Methodcall:image];
//Image_camera=image;
// NSAutoreleasePool *apool = [[NSAutoreleasePool alloc] init];
//printf("first\n");
// [self performSelector:@selector(Methodcall) withObject:nil afterDelay:1];
//printf("ok\n");
//[apool release];
}
-(void)Methodcall:(UIImage *)image{
ImageDisplayViewController *ImageDisplayViewController_obj=[[ImageDisplayViewController alloc] initWithNibName:@"ImageDisplayViewController" bundle:nil];
ImageDisplayViewController_obj.image_FRomCamera=image;
NSLog(@"image===>%@ camera==>%@",image,ImageDisplayViewController_obj.image_FRomCamera);
[self.navigationController pushViewController:ImageDisplayViewController_obj animated:YES];
// [ImageDisplayViewController_obj release];
}
-(IBAction)TakePhotoCamera:(id)sender{
@try
{
UIImagePickerController *picker_camera = [[UIImagePickerController alloc] init];
picker_camera.sourceType = UIImagePickerControllerSourceTypeCamera;
picker_camera.delegate = self;
[self presentModalViewController:picker_camera animated:YES];
[picker_camera release];
}
@catch (NSException *exception)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Camera" message:@"Camera is not available " delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
有没有人帮帮我。
提前致谢。