gpt4 book ai didi

ios - 升级到 iOS8 后,UITableView didSelectRowAtIndexPath 不工作

转载 作者:可可西里 更新时间:2023-11-01 04:08:11 25 4
gpt4 key购买 nike

我有一个 iOS 应用程序,其中包含多个 UITableViews,所有这些都按预期工作.我升级应用程序以处理 iOS8

从那时起,我在将自定义单元格加载到表格 View 时遇到了问题,谁的 Nib 在 ib 中选中了“使用自动布局”框。然后,我在我的自定义单元格上取消选中所有这些,从那时起,我所有 UITableView 的单元格不仅不调用 didSelectRowAtIndex 路径方法,而且在触摸时也不会突出显示。

我已通过添加

检查所有单元格是否处于事件状态
if(cell.userInteractionEnabled){NSLog(@"is enabled");}else{NSLog(@"is not enabled");}

所有加载的单元格都将“已启用”写入日志

我正在 Storyboard中通过 ib 设置委托(delegate)和数据源,在我更改“使用自动布局”并升级以在 iOS 8 上运行之前,所有这些都在工作。

我错过了什么?

这是我创建单元格的代码

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

static NSString *CellIdentifier = @"TableCellWithNumberCellIdentifier";
if( events.count>indexPath.row &&[[[events objectAtIndex:indexPath.row] objectForKey:@"tag"] integerValue] == -1)
{
EventsMonthSeparator *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell.translatesAutoresizingMaskIntoConstraints=NO;
cell = (EventsMonthSeparator *)[EventsMonthSeparator cellFromNibNamed:@"EventsMonthSeparator"];
cell.date.text=[[events objectAtIndex:indexPath.row] objectForKey:@"date"];
[Functions setFontFamily:@"Neutra Display" forView:cell andSubView:YES];
if(cell.userInteractionEnabled){NSLog(@"is enabled");}else{NSLog(@"is not enabled");}
}
return cell;
}else
{
eventsRow *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell.translatesAutoresizingMaskIntoConstraints=NO;
cell = (eventsRow *)[eventsRow cellFromNibNamed:@"eventsRow"];
cell.description.text=[[events objectAtIndex:indexPath.row] objectForKey:@"name"];
cell.timedate.text=[[events objectAtIndex:indexPath.row]objectForKey:@"date"];
cell.image.image=[UIImage imageNamed:@"tiledrinks"];
cell.status.text=[Functions statusForIndex:[[[events objectAtIndex:indexPath.row] objectForKey:@"booked"] intValue]];
[Functions setFontFamily:@"Neutra Display" forView:cell andSubView:YES];
cell.tag=1;
[cell setSelectionStyle:UITableViewCellSelectionStyleBlue];
if(cell.userInteractionEnabled){NSLog(@"is enabled");}else{NSLog(@"is not enabled");}
}
return cell;
}
}

最佳答案

请检查您的自定义单元格的 xib 中的 Auto-Layout 是否为 OFF(未选择的 tickMark)。

并在您的 TableView 中检查此默认设置,如下图所示 enter image description here

我曾经遇到过同样的问题,我在 TableView 的 attribute inspectorselection 属性中给出了 NO Selection

如果你做了同样的事情,那么在那里给出Single selection

希望对您有所帮助!

关于ios - 升级到 iOS8 后,UITableView didSelectRowAtIndexPath 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26444683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com