カメラで画像をキャプチャしています。次に、キャプチャした画像を表示する次のコントローラーに移動します。イメージ画面のキャプチャに戻り、このサイクルが 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;
}