我有一个tableView有两个部分我想在节标题(动作按钮)中添加一个按钮可以在样本图像中做同样的事情吗?添加按钮部分标题?
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
if(section ==0)
{
return 0;
}
else{
UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 300.0, 20.0)];
UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd];
[button setFrame:CGRectMake(275.0, 5.0, 30.0, 30.0)];
button.tag = section;
button.hidden = NO;
[button setBackgroundColor:[UIColor clearColor]];
[button addTarget:self action:@selector(insertParameter:) forControlEvents:UIControlEventTouchDown];
[myView addSubview:button];
return myView; }
}
@Bhargavi的UIView *观的高度= [[UIView的页头] initWithFrame:方法CGRectMake(10.0,0.0,300.0,44.0)]; //创建按钮对象 UIButton * headerBtn = [[UIButton alloc] initWithFrame:CGRectZero]; headerBtn.backgroundColor = [UIColor clearColor]; headerBtn.opaque = NO; headerBtn.frame = CGRectMake(10.0,0.0,100.0,30。0); [headerBtn setTitle:@“”forState:UIControlEventTouchUpInside]; [headerBtn addTarget:self action:@selector(ActionEventForButton :) forControlEvents:UIControlEventTouchUpInside]; [查看addSubview:headerBtn]; return View; – 2013-03-15 08:52:28
如果你在viewForHeaderInSection中试过,那么问题是什么? – 2013-03-15 08:56:43
@Bhargavi请检查我的代码 – 2013-03-15 08:58:59