-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    static NSString *simpleTableIdentifier = @"cell";

    simpleCell = [self.dashboardListView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    if (simpleCell == nil) {

        simpleCell = [[SimpleTableCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
        simpleCell.selectionStyle = UITableViewCellSelectionStyleNone;

    }

    ///tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(sectionTapped)];
    ///[simpleCell.contentView addGestureRecognizer:tap];

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setFrame:simpleCell.frame];
    [button addTarget:self action:@selector(sectionTapped) forControlEvents:UIControlEventTouchUpInside];
    [button setBackgroundColor:[UIColor clearColor]];
    [simpleCell.contentView addSubview:button];

    NSDictionary *dict = [cellnames objectAtIndex:section];

    simpleCell.cellName.text = (NSString *)[dict valueForKey:@"cellname"];
    simpleCell.count.text = [[countArray objectAtIndex:section]stringValue];


    return simpleCell;

}

上面的代码工作正常。

问题是:- 当我长按 tableView 上的 simpleCell 时它会崩溃。

我收到崩溃日志



任何建议都非常感谢。

谢谢,

最佳答案

你可能想试试
cell.contentView.userInteractionEnabled = NO;有同样的问题。禁用 userInteraction 为我解决。

10-08 06:12