UIImagePIckerController所选图像始终为NIL

时间:2011-04-19 17:27:24

标签: ios uiimage uiimagepickercontroller

我正在尝试关注代码,但返回的图片始终为NIL。我错过了什么。

我累了......

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    //on selected

    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

    NSData *imgData = UIImageJPEGRepresentation(image, 1.0);

    NSString *imageString = [[NSString alloc] initWithBytes: [imgData bytes] length:[imgData length] encoding:NSUTF8StringEncoding];

    //NSLog(@"Image Data: %@", imageString); it returns Nothing except "Image Data: "

    [picker dismissModalViewControllerAnimated:YES];
    [picker release];
}

我也试过了......

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    //on selected

    [picker dismissModalViewControllerAnimated:YES];
    [picker release];

    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

    NSData *imgData = UIImageJPEGRepresentation(image, 1.0);

    NSString *imageString = [[NSString alloc] initWithBytes: [imgData bytes] length:[imgData length] encoding:NSUTF8StringEncoding];

    //NSLog(@"Image Data: %@", imageString); it returns Nothing except "Image Data: "
}

两个代码都不返回,[imgData length]为零。我错过了什么?

0 个答案:

没有答案