当我尝试使用 UIImagePickerController 拍摄多张照片时,我的应用程序崩溃了。所以,我第一次拍照时一切都很好,第二次应用程序崩溃时没有任何错误消息。我确实第一次得到这个:
2013-01-11 16:36:24.178 DoodleStash[26778:907] Received memory warning.
这是我用来拍照的代码:
- (IBAction)takePhoto:(id)sender {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage, nil];
[self presentViewController:imagePicker animated:YES completion:nil];
self.isNewDoodle = TRUE;
}}
这是我用来保存照片的
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
[self dismissViewControllerAnimated:YES completion:nil];
if ([mediaType isEqualToString:(NSString *) kUTTypeImage]) {
self.doodleImage = [info objectForKey:UIImagePickerControllerOriginalImage];
// Check to make sure the image is new
if (self.isNewDoodle == TRUE) {
UIImageWriteToSavedPhotosAlbum(self.doodleImage, self, @selector(image:finishedSavingWithError:contextInfo:), nil);
}
[self performSegueWithIdentifier:@"confirmUploadSegue" sender:self];
}}
非常感谢您对此的任何帮助。完整代码在这里https://gist.github.com/4515007