问题描述
- 通过默认相机拍照,反应很慢
-
用iphone的默认照相机,使用UIImagePickerView
控制器拍照,但是运行的非常慢。-(IBAction)takePhoto:(id)sender { if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) { imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera; [self presentModalViewController:imgPicker animated:YES]; } } -(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { UIImage *pickedImage = [info objectForKey:UIImagePickerControllerOriginalImage]; [self dismissModalViewControllerAnimated:YES]; NSData *imageData = UIImagePNGRepresentation(pickedImage); path = [SAVEDIMAGE_DIR stringByAppendingPathComponent:@"image.png"]; [imageData writeToFile:path atomically:YES]; [tableview reloadData]; }
解决方案
试试这样:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
[self presentViewController:imagePicker animated:YES completion:nil];
时间: 2024-10-31 18:06:00