应用程序崩溃在UItableCellSection长按

-(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时,它正在崩溃。

我得到崩溃日志

*** – [SimpleTableCell hash]:发送到解除分配的实例0x7f86dc0b2420的消息

任何build议,高度赞赏。

谢谢,

你可能想尝试

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

我有同样的问题,我解决了它使用UIView * objView代替使用CustomTableCell。

尝试这将有助于。