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 に答える