阅读背景:

当我单击特定索引按钮状态时,我在表视图单元格中有按钮会改变

来源:互联网 
- (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];

}
- (UITableViewCell *)tableView:(UITableView *)t



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: