2015-10-16 53 views
-2

我在tableview控制器中使用自定義單元類。當您使用自定義單元格時調用cellForRowAtIndexPath?

當我在cellForRowAtIndexPath NSLog(@"method called"):的tableviewcontroller中包含語句時,它似乎不會被調用。

當您擁有自定義單元格時,可能不會調用此方法嗎?

編輯:如果沒有行返回

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSLog(@"cell for row at index path called"); 
    NSDictionary *item= [self.getItems objectAtIndex:indexPath.row];  
    //This sets place in storyboard VC 
    IDTVCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"Cell"]; 
    cell.item = item; 
    if (cell == nil) { 
     cell = [[IDTVCell alloc] initWithStyle:UITableViewCellStyleDefault 
           reuseIdentifier:@"Cell"]; 
    } 
    return cell; 
    } 
+0

用你實際的'cellForRowAtIndexPath'方法更新你的問題。還要確保您的數據源方法返回非零數量的行。 – rmaddy

+0

然而,numberofrowsinsection方法返回許多指定的值,即返回1返回1.但是,cellforrowatindexpath似乎沒有被調用。 – user1904273

+1

如果在該部分中有非零的部分和非零行,則應該調用'cellForRow ...'方法。你是否證實'numberOfRowsInSection:'被調用? – rmaddy

回答

0

要回答你的問題 - 是的,它是。

可能有n個原因爲什麼cellForRowAtIndexPath:沒有被調用。這可能是因爲未設置delegate/dataSource或未設置框架UITableView等等。

您應該很容易找到一個解決方案,其中包含更多在線研究並關閉您的代碼。

相關問題