我有一个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'。
如何让我的类别方法处理按钮?