我有一种制作按钮的方法。参数是文本颜色位置 x 位置 y 按钮类型和方法(注意:此方法在一个类中)
-(UIButton *)makeButton :(NSString *)string :(UIColor*)textColor :(CGFloat)posx :(CGFloat)posy :(UIButtonType)type :(SEL)run
{
UIButton *button =[UIButton buttonWithType:type];
[button addTarget:self action:run forControlEvents:UIControlEventTouchUpInside];
[button setTitle:string forState:UIControlStateNormal];
button.titleLabel.font =[UIFont systemFontOfSize:11];
[button setTitleColor:textColor forState:UIControlStateNormal];
CGSize stringSize =[string sizeWithFont:[UIFont systemFontOfSize:11]];
[button setFrame:CGRectMake(posx, posy, stringSize.width+10, stringSize.height+5)];
return button;
}
我正在调用这样的方法。
UIButton *btnGidenler= [methods makeButton:anlik :[methods RGBR:0 G:135 B:222 A:1.0] :10 :5:(UIButtonType)UIButtonTypeCustom :@selector(gidenKisiler)];
[viewGidenler addSubview:btnGidenler];
和@selector(btnGidenler)
基本方法-(void)gidenKisiler{ //just alert }
当我点击按钮时,我的应用程序崩溃了。为什么选择器不起作用?
粉碎错误
@autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); }