2014-06-28 93 views
1

你好,我一直在困難的問題一段時間。我試圖在ViewController中加載兩個TableView。我正在使用自定義UITableViewCells與筆尖爲一個UITableView和我正在使用正常UITableViewCell爲另一個。當UITableView,註冊筆尖被載入,但事情正在工作時,與非定製TableViewCellUITableView加載我真的發現了以下錯誤:在視圖控制器中的兩個UITableView加載器

unable to dequeue a cell with identifier Cell1 - must register a nib or a class for the identifier or connect a prototype cell in a storyboard' 

這是我的代碼:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (tableView==tbl_search) 
    { 
     cell_intelisearch *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; 
     if (cell==nil) 
     { 
      cell =[[cell_intelisearch alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"]; 
     } 

     [cell.btn_options addTarget:self action:@selector(add_Action_sheet:) forControlEvents:UIControlEventTouchUpInside]; 
     [self configureCell:cell atIndexPath:indexPath]; 

     return cell; 

    } 
    //------FOR POP UP TABLE------ 
    else 
    { 
     static NSString *CellIdentifier = @"Cell1"; 

     UITableViewCell *cell1 = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 
     if (cell1==nil) 
     { 
      cell1 =[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
     } 

     cell1.textLabel.text=[arr_pop_up_status objectAtIndex:indexPath.row]; 
     return cell1; 
    } 
} 

任何幫助會非常感激。

回答

0

在IB中,對於非自定義表格,請確保繪製原型單元格。在屬性檢查器中,將其樣式設置爲其中一種標準樣式,並將其標識設置爲Cell1以與您在代碼中使用的標識符相匹配。

+0

感謝您的答案...但我應該提到的是,我所做的非定製按代碼表 – user3744496

0

對於非自定義單元格下面的代碼應該寫在或viewDidLoad中的cellForRowAtIndexPath它可以解決您的問題

[tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellIdentifier]; 
相關問題