应用程序崩溃在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。
尝试这将有助于。
- UITableView -headerViewForSection返回(null)
- iOS UITableViewCellAccessoryCheckmark每次滚动都可见
- 在Firebase中填充UITableView一次设置单元格数量
- 为TableView中的所有单元格设置标签的正确方法
- 更改自定义tableViewCell的背景颜色
- 表视图麻烦与出列单元格
- 如何使用commitEditingStyle从plist删除数组?
- 如果在一个ViewController中使用两个UITableView,而另一个使用自定义单元格refrence,而另一个则很简单
- 如何使数组中的每个string成为自己的UITableViewCell,每个string都在自己的部分中?