Lucas Rocha
Lucas Rocha

Reputation: 19

Show image on Xcode

I'm a beginner in xcode, and I want to make an projec where I have some buttons, when I touch the button, an method shows an image, but its not working.

- (IBAction)button01:(id)sender 
{
    CGRect frame;

    frame.origin.x = 0;
    frame.origin.y = 0;
    frame.size = CGSizeMake(580, 325);

    UIImage *image = [UIImage imageNamed:@"lightBox.png"];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    imageView.frame = frame;
}

Somebody can help me please?!

Thanks!

Upvotes: 0

Views: 2071

Answers (1)

user1388320
user1388320

Reputation:

Try to do it:

- (IBAction)button01:(id)sender 
{
    CGRect frame;

    frame.origin.x = 0;
    frame.origin.y = 0;
    frame.size = CGSizeMake(580, 325);

    UIImage *image = [UIImage imageNamed:@"lightBox.png"];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:background];
    [self.view addSubview:imageView];
    bgView.frame = frame;
}

I'm adding it as subview, so it'll appear.

Upvotes: 1

Related Questions