我正在通过相机拍摄图像。然后我移动到下一个控制器,在其中显示捕获的图像。我回去捕捉图像屏幕,这个循环持续 10 到 15 次。在此之后,当我尝试捕获图像时,应用程序会通过发出“内存不足警告”而崩溃。这是代码:
- (IBAction) takePhoto:(id) sender
{
/*
tempControl *intermediate=[[tempControl alloc] initWithNibName:@"tempControl" bundle:nil];
[self.navigationController pushViewController:intermediate animated:YES];
[intermediate release];
*/
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
imagePickerController= [[UIImagePickerController alloc] init];
[imagePickerController setMediaTypes:[NSArray arrayWithObjects:(NSString *)kUTTypeImage, nil]];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:imagePickerController animated:YES];
}
else{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Camera Alert" message:@"Device Lacks Camera" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
[alert release];
alert = nil;
}
}
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo{
[picker dismissModalViewControllerAnimated:NO];
[picker release];
picker =nil;
/*
cropReciept *recieptToCrop=[[cropReciept alloc] initWithNibName:@"cropReciept" bundle:nil];
[recieptToCrop setReciept:image];
[self.navigationController pushViewController:recieptToCrop animated:YES];
[recieptToCrop release];
*/
OCRDemoViewController *recieptToCrop=[[OCRDemoViewController alloc] initWithNibName:@"CropTestViewController" bundle:nil];
[recieptToCrop setImageToCrop:image];
if ([self.selectedTicketType isEqualToString:@"MAXI QuickPick"]) {
recieptToCrop.selectedValueOfTicket=50;
recieptToCrop.drawNumber=self.selectedDrawNumber;
}
else if ([self.selectedTicketType isEqualToString:@"JUMBO QuickPick"]) {
recieptToCrop.selectedValueOfTicket=36;
recieptToCrop.drawNumber=self.selectedDrawNumber;
}
else if ([self.selectedTicketType isEqualToString:@"MEGA QuickPick"]) {
recieptToCrop.selectedValueOfTicket=24;
recieptToCrop.drawNumber=self.selectedDrawNumber;
}
else if ([self.selectedTicketType isEqualToString:@"REGULAR QuickPick"]) {
recieptToCrop.selectedValueOfTicket=12;
recieptToCrop.drawNumber=self.selectedDrawNumber;
}
else if ([self.selectedTicketType isEqualToString:@"SUPER QuickPick"]) {
recieptToCrop.selectedValueOfTicket=18;
recieptToCrop.drawNumber=self.selectedDrawNumber;
}
[self.navigationController pushViewController:recieptToCrop animated:YES];
[recieptToCrop release];
recieptToCrop=nil;
}