- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellClassName = @"CarDriverTableViewCell";
CarDriverTableViewCell *cell = (CarDriverTableViewCell *)[tableView dequeueReusableCellWithIdentifier: CellClassName];
if (cell == nil)
{
cell = [[CarDriverTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellClassName];
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CarDriverTableViewCell"
owner:self options:nil];
cell = [nib objectAtIndex:0];
cell.backgroundColor=[UIColor blackColor];
}
UILabel *lbltime=(UILabel *)[cell viewWithTag:1];
UILabel *lbldriver=(UILabel *)[cell viewWithTag:2];
UILabel *lbllicence=(UILabel *)[cell viewWithTag:4];
bookbtn=(UIButton *)[cell viewWithTag:5];
// [bookbtn addTarget:self action:@selector(btnclicked:) forControlEvents:UIControlEventTouchUpInside];
lbltime.text=[[arrnames valueForKey:@"time"]objectAtIndex:indexPath.row];
lbldriver.text=[[arrnames valueForKey:@"name"]objectAtIndex:indexPath.row];
lbllicence.text=[[arrnames valueForKey:@"license_plate"]objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
bookbtn.tag=indexPath.row;
[bookbtn addTarget:self action:@selector(btnclicked:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)btnclicked:(id)sender
{
[bookbtn setTitle:@"Pending" forState:UIControlStateNormal];
}
当我点击特定的索引按钮时,我的按钮名称将会改变,剩下的单元格将被选中。
当我将按钮名称的响应作为接受和拒绝时,只会选择我的表格视图单元格。
答案 0 :(得分:0)
试试这个
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
bookbtn.tag=indexPath.row;
[bookbtn addTarget:self action:@selector(btnclicked:) forControlEvents:UIControlEventTouchUpInside];
[yourtableview realoadData];
}
答案 1 :(得分:0)
可能是:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
bookbtn.tag=indexPath.row;
[bookbtn addTarget:self action:@selector(btnclicked:) forControlEvents:UIControlEventTouchUpInside];
return bookbtn
}