UIImagePickerController random behavior
Posted
by pion
on Stack Overflow
See other posts from Stack Overflow
or by pion
Published on 2010-04-11T20:52:14Z
Indexed on
2010/04/11
21:03 UTC
Read the original article
Hit count: 295
iphone
|uiimagepickercontroller
I have the following code snippets:
@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];
}
It works 80% of the time -- I could get the picture correctly.
The problem is that it occasionally failed to take a picture. When tracing the code, I found out that it occasionally goes to -PinRecordNewTableViewController:viewDidUnload. This is where it fails because it set nil to all ivars.
What did I do wrong? Did I miss something so it behaves "randomly"?
Thanks in advance for your help.
© Stack Overflow or respective owner