2 developerwab developerWab 于 2013.01.24 15:14 提问

通过默认相机拍照,反应很慢

用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];
}

1个回答

Kakalapa1986
Kakalapa1986   2013.01.24 16:17
已采纳

试试这样:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];

imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

imagePicker.delegate = self;

[self presentViewController:imagePicker animated:YES completion:nil];
Csdn user default icon
上传中...
上传图片
插入图片