2014-10-18 120 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

相關問題