0

我是xcode的初学者,我想制作一个有一些按钮的项目,当我触摸按钮时,一个方法会显示图像,但它不起作用。

- (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;
}

有人可以帮助我吗?!

谢谢!

4

1 回答 1

1

尝试这样做:

- (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;
}

我将它添加为子视图,所以它会出现。

于 2012-05-20T21:20:45.223 回答