How can I refresh my view after assign an image to an UIImageView object?
ios, iphone, uiimage, uiimageview
Solution
I'm guessing `imgToDisplay` is an `UIImageView` you created in Interface Builder and connected via outlet? In that case, you should be setting its `image` property rather than the pointer to image view itself. Your way, pointer now points to new instance of image view that was not added to view hierarchy and will therefore not be displayed. You just need to set an image to existing image view that is already displayed.
self.imgToDisplay.image = [[UIImage alloc] initWithData:image];
If you are creating this image view in code on purpose, then you need to add it to view hierarchy.
[self.view addSubview:self.imageToDisplay];
(don't forget to release image and or/image view if not using ARC).
Problem
I have an UIImageView outlet when someone clicks a button depending what button they click. here is my code: ``` UIImage *img = [[UIImage alloc] initWithData:image]; self.imgToDisplay = [[UIImageView alloc]initWithImage:img]; // I try to use this to see the image: [self.imgToDisplay setNeedsDisplay]; ``` but didn't work. Does anyone know how can I display the image on my UIImageView? I'll really appreciate your help.