在cell 里 写button 为什么 没有点击效果 一点反映没有??- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{ actionBtn = [[UIButton alloc]init];
actionBtn.frame = CGRectMake(210, 75, 100, 30);
[actionBtn setBackgroundImage:[UIImage imageNamed:@"commonMiddleBt.png"] forState:UIControlStateNormal];
[actionBtn setBackgroundImage:[UIImage imageNamed:@"commonMiddleBt_on.png"] forState:UIControlStateHighlighted];
[actionBtn addTarget:self action:@selector(docking:) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:actionBtn];
}
点击button 一点效果没有啊。。
{ actionBtn = [[UIButton alloc]init];
actionBtn.frame = CGRectMake(210, 75, 100, 30);
[actionBtn setBackgroundImage:[UIImage imageNamed:@"commonMiddleBt.png"] forState:UIControlStateNormal];
[actionBtn setBackgroundImage:[UIImage imageNamed:@"commonMiddleBt_on.png"] forState:UIControlStateHighlighted];
[actionBtn addTarget:self action:@selector(docking:) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:actionBtn];
}
点击button 一点效果没有啊。。
@property (nonatomic,retain) UIButton * actionBtn;
然后在cell实例化时再:
[cell.actionBtn addTarget:self action:@selector(docking:) forControlEvents:UIControlEventTouchUpInside];
再者就是创建button的代码放到这个方法中比较合适
-(void)layoutSubview
在这个方法里 加了句这个 就成了我这个 cell是比较大 因为 这个样式