Problem displaying image with UIImageView

0

When displaying image included in the project in .png format using UIImageView to only display the simulator screen is left 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 is left blank.

NOTE: I added UIImageView to Sotryboard and I connected it with _imageViewLocal .

I just completed the following test: - I removed the UIImageView created in 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?

    
asked by anonymous 14.01.2015 / 19:12

2 answers

0

Xcode behaved very strangely. But now it worked.

I made a direct assignment to the Object property of the Object. But he had already tried the same operation and it did not work. But now it worked.

Note: UIImageView added from the Storyboard.

Code:

imagemLocal = [UIImage imageNamed:@"button.png"];
 _imageViewTesteFundo.image = imagemLocal;
    
14.01.2015 / 19:41
1

Try to use this:

UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 100, 100)];
    [imgView setImage:[UIImage imageNamed:"image.png"]];
    [self.view addSubview: imgView];
    
21.01.2015 / 19:18