开发者

issues with "imagePickerController: didFinishPickingMediaWithInfo:"

I keep getting an unused variable warning. I'm trying to have a modal view appear, where a user selects a photo, and I want to use that selected image in an UIImageView.

Not sure if this is enough info but would really appreciate any help.

- (IBAction) buttonPressed:(UIButton *)sender { 
    UIImagePickerController 开发者_Python百科*picker = [[UIImagePickerController alloc] init]; 
    picker.delegate = self;
    [self presentModalViewController:picker animated:YES];
    [picker release];
}

- (void) imagePickerController:( UIImagePickerController *)picker didFinishPickingMediaWithInfo: (NSDictionary *)info { 
    UIImage *image = [info objectForKey: UIImagePickerControllerOriginalImage];
}


you're getting the warning because you're not using the image object anymore. You must save this image in some class object to use it somewhere in the code, warning will automatically vanish if you do that. Or just for removing the warning you can do:

-(void) imagePickerController:( UIImagePickerController *)picker didFinishPickingMediaWithInfo: (NSDictionary *)info {  
 UIImage *image;  
 image=[info objectForKey: UIImagePickerControllerOriginalImage];   
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜