长按UItableCellSection导致应用程序崩溃 [英] The application is Crashing on UItableCellSection long press
本文介绍了长按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哈希]:消息发送到已释放实例0x7f86dc0b2420`
*** -[SimpleTableCell hash]: message sent to deallocated instance 0x7f86dc0b2420`
任何建议都将受到高度赞赏.
any suggestions are highly appreciated.
谢谢
推荐答案
您可能想尝试
cell.contentView.userInteractionEnabled = NO;
有同样的问题.禁用userInteraction为我解决了.
cell.contentView.userInteractionEnabled = NO;
had the same issue. disabling userInteraction resolved for me .
这篇关于长按UItableCellSection导致应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文