0
When displaying image included in project format .png
using UIImageView
to only display the simulator screen is blank.
Code used:
UIImage* imagemLocal = [UIImage imageNamed:@"button.png"];
_imagemViewLocal = [UIImageView alloc]initWithImage:imagemLocal];
Or:
UIImage* imagemLocal = [UIImage imageNamed:@"button.png"];
_imagemViewLocal = [[UIImageView alloc]init];
[_imagemViewLocal setImage: imagemLocal];
The result is the same ImageViewLocal
goes blank.
NOTE: I added one UIImageView
for Sotryboard
and connected it with _imageViewLocal
.
I ended up performing the following test:
- I removed the UIImageView
raised in the Storyboard
and did everything directly in the code. And displayed the image with the following code:
UIImageView* imageViewLocal = [[UIImageView alloc]init];
imagemLocal = [UIImage imageNamed:@"button.png"];
imageViewLocal = [[UIImageView alloc]initWithImage:imagemLocal];
[self.view addSubview: imageViewLocal];
How to solve the reported problem?
Have you checked whether
imageNamed
is returningnil
?– André Ribeiro
Yes already checked, is not returning nil, is loading the image normally. Very strange this.
– Tiago Amaral
Updating question!
– Tiago Amaral
I did a test creating everything in the code, and it worked, but I still prefer to use the storyboard because to speed up the process.
– Tiago Amaral
Do a test: add again to
ImageView
in Storyboard, plug it in with the variable and change the background color just to see if it’s visible in the current view.– André Ribeiro
I’m gonna take the test!
– Tiago Amaral
Yes, I changed the background color to red and it worked with the Uiimageview link created by Storyboard
– Tiago Amaral
Now it worked!!! I’ll post the answer!!! very crazy Xcode today huh!! My, I think it’s the heat! rs
– Tiago Amaral