我用UIPickerViewController拍照。它工作了80%,但似乎是随机的,它不能拍照。在跟踪代码时,我发现它偶尔会转到
-PinRecordNewTableViewController:viewDidUnload. 这就是它失败的地方,因为它将nil设置为all ivar。
@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];
}我做错什么了?我是不是遗漏了什么导致它“随机”行为的东西?
提前感谢您的帮助。
发布于 2010-04-12 04:56:06
如果它调用了viewDidUnload,那么很可能是你的应用程序内存不足。这可能是一个问题,或者仅仅是在手机中编辑大图像的结果。
发布于 2011-02-21 17:09:07
如果您尝试拍摄多张照片,请将当前照片保存到应用程序的文档区。它释放了内存。这样,就可以避免内存警告。
如果正在调用ViewDidUnload,您可能会考虑在didReceiveMemoryWarning中保存应用程序的相关状态,然后在viewDidLoad中恢复它。这是使用NSUserDefaults类完成的
https://stackoverflow.com/questions/2618665
复制相似问题