UIButton不起作用

时间:2014-04-25 12:24:31

标签: objective-c cocoa uibutton

我用以下代码编写了一个uibutton

btnSet = [UIButton buttonWithType:UIButtonTypeCustom];
btnSet.frame = CGRectMake(0, 0, 146, 30);
[btnSet setBackgroundImage:[UIImage imageNamed:@"btnbg.png"] forState:UIControlStateSelected];
[btnSet addTarget:self action:@selector(visitSet) forControlEvents:UIControlEventTouchUpInside];
[btnSet setTitle:@"SetIt" forState:UIControlStateNormal];
btnSet.titleLabel.font = [UIFont systemFontOfSize:12.0f];
btnSet.titleLabel.textColor = [UIColor blackColor];
[self.view addSubview:btnSet];

- (void) visitSet
 {
    NSLog(@"visit set");
    btnSet.selected = YES;
 }
选择状态时按钮的背景,但代码不起作用,点击按钮后没有响应,没有日志输出。

0 个答案:

没有答案
相关问题