iPhone: UIImagePickerController Randomly Fails to Take Picture
- by pion
I use a UIPickerViewController to take picture. It works 80% but seemingly at random it fails to take a picture. In tracing the code I found out that it occasionally goes to
-PinRecordNewTableViewController:viewDidUnload.
That is where it fails because it set nil to all ivars.
@interface PinRecordNewTableViewController : UITableViewController {
}
...
@implementation PinRecordNewTableViewController
...
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
...
PinRecordNewPicture *pinRecordNewPicture = [[PinRecordNewPicture alloc] initWithNibName:@"PinRecordNewPicture" bundle:nil];
pinRecordNewPicture.delegate = self;
[self.navigationController pushViewController:pinRecordNewPicture animated:YES];
[pinRecordNewPicture release];
...
}
@interface PinRecordNewPicture : UIViewController
...
@implementation PinRecordNewPicture
...
- (void)picturePicker:(UIImagePickerControllerSourceType)theSource {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = theSource;
picker.allowsEditing = YES;
[self presentModalViewController:picker animated:YES];
[picker release];
}
- (IBAction) takePicture:(id)sender {
UIImagePickerControllerSourceType source = UIImagePickerControllerSourceTypeCamera;
if ([UIImagePickerController isSourceTypeAvailable:source]) {
[self picturePicker:source];
}
What did I do wrong? Did I miss something that causes it to behave "randomly"?
Thanks in advance for your help.