UIRoundedRectButton没有响应UIView类别方法

时间:2013-03-27 22:05:23

标签: objective-c xcode

我有一个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'。

如何让我的类别方法处理按钮?

0 个答案:

没有答案