I am working on an application for iPad, it is working fine until i reached this point:
The app shows the popover for the photo library, but when I choose the photo, the popover doesn't hide, and I also want it to view the selected image in a UIImageView, however i do not knowhow.
I am sure there is something wrong in the didFinishpickingMediaWithInfo function. here is the function's code:
-(void) imagePickerController:(UIImagePickerController *)picker didFinishpickingMediaWithInfo:(NSDictionary *)info{
//bgImage is a UIImageView
bgImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
// Dismiss UIImagePickerController and release it
[picker dismissModalViewControllerAnimated:YES];
[picker.view removeFromSuperview];
[picker release];}
My first question is: What am i supposed to add to this function for viewing the selected photo in the UIImageView?
2- I have read that I should've开发者_如何学Go used UIImage instead of UIImageView.. Is this true? If yes, what about the interface builder? there is nothing called UIImage ?
Many thanks in advance.. :-) Regards, Rawan
First add an UIImageView in IB the create IBOutlet for that UIImageView in your .h file then connect UIImageView to this IBOutlet in IB. Then in your didFinishpickingMediaWithInfo get the selectedImage in an UIImage instance and then call setImage to that IBOutlet you created for UIImageView and pass the selected image instance to setImage.
-(void) imagePickerController:(UIImagePickerController *)picker didFinishpickingMediaWithInfo:(NSDictionary *)info{
// TempImage is a UIImage instance
TempImg = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
//bgImage is a UIImageView instance and it's connected in the IB
[bgImage setImage:TempImg];
// Dismiss UIImagePickerController and release it
[picker dismissModalViewControllerAnimated:YES];
[picker.view removeFromSuperview];
[picker release];
}
I am really sorry for bothering, and really appreciating your given time.. :-)
精彩评论