2014-10-18 83 views
5

我有一个iOS应用程序,其中有几个UITableViews,其中所有这些应用程序均按预期工作 。我升级的应用程序来处理iOS8UITableView didSelectRowAtIndexPath升级到iOS8后无法正常工作

因为那时我有一个加载自定义单元格到表视图谁的笔尖在ib中勾选'使用自动布局'的问题。然后我取消所有这些在我的自定义单元格中的选中,从那以后,我所有UITableViews的单元格不仅不调用didSelectRowAtIndex路径方法,而且在触摸时不突出显示。

我必须检查所有活动单元的加入

if(cell.userInteractionEnabled){NSLog(@"is enabled");}else{NSLog(@"is not enabled");} 

所有装载的细胞的写上“允许”到日志

我通过IB设置委托和数据源在故事板中,所有这些工作都在我改变“使用自动布局”并升级到在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; 
    } 
} 
+0

什么问题,你是否也有加载自定义单元格与自动布局表视图打开?解决这个问题会更好,并继续使用apt布局。 – rdelmar 2014-10-18 23:19:32

+0

当它被打开它完美的工作 – 2014-10-19 08:05:35

回答

15

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

,并在您检查TableView这个默认设置, 如下图像enter image description here

附着在我有同样的问题一次,在那里我有给NO Selection在TableView中的的selection财产。

如果您已经完成了相同的操作,则在那里给Single selection

希望这会帮助你!

+0

嘿,你救了我的一天...如果“选择=没有选择”它不会调用didSelectRowAtIndexPath委托。 – 2015-06-23 10:25:36

+0

@SameeraR。 ,这是我的荣幸,我会帮助别人:) – 2015-06-26 10:56:24

2

如果您选择了自动布局,cell.translatesAutoresizingMaskIntoConstraints=NO;将否定的自动布局Xcode提供。 另外,你可以检查你的所有tableViews的代表是否完好?如果您的委托没有设置,则在表格视图单元格上点击不会调用'didSelectRow'方法。

+0

在ib中设置了deligates和datascource。方法cellForRowAtIdexPath,willDisplayCell forRowAtIndexPath和heightForRowAtIndexPath都正常工作 – 2014-10-23 14:21:33

+0

只需检查:尝试在你的didSelectRow方法中放置一个NSLog(“Hello”)并注释掉其他所有内容。 – 2014-10-23 14:25:44

+0

完成此操作并且按下时没有记录任何内容 – 2014-10-23 17:08:14

0

可以“单选择编辑在”选择的TableView, 例如: enter image description here

相关问题