0

UIView のフレームのサイズを変更する UIView カテゴリ メソッドがあります。

-(void)setFrameWidth:(NSInteger)aWidth andHeight:(NSInteger)aHeight
{
    CGRect labelFrame = self.frame;
    labelFrame.size = CGSizeMake(aWidth, aHeight);
    self.frame = labelFrame;
}

ただし、UIRoundedRectButton に適用すると:

//button for options
    optionsButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [optionsButton setTitle:@"Options" forState:UIControlStateNormal];
    [optionsButton addTarget:self action:@selector(goToOptions:) forControlEvents:UIControlEventTouchUpInside];
    [optionsButton setFrameWidth:200 andHeight:50];
    optionsButton.center = CGPointMake(SCREEN_X_LENGTH_HALF, SCREEN_Y_LENGTH_TWO_THIRDS);
    [self.view addSubview:optionsButton];

「-[UIRoundedRectButton setFrameWidth:andHeight:]: 認識されないセレクターがインスタンス 0x718a600 に送信されました」と不平を言います。

カテゴリ メソッドをボタンで動作させるにはどうすればよいですか?

4

0 に答える 0