我有一個UIView包含兩個UITableViews,它們在UIView的導航欄中使用分段控件進行切換。從筆尖加載自定義單元沒有按時完成
第一個表(成分)只使用標準單元格,並且工作正常。
第二個表(食譜)使用從筆尖加載的自定義單元格。問題是,當應用程序啓動和配方表的最後可見的(從狀態保存),當視圖顯示在細胞用標準細胞呈遞。如果用戶循環提到的分段控制,它們在返回到食譜表格後按預期顯示。在視圖控制器的tableView:cellForRowAtIndexPath:
相關部分:
// Check that we are displaying the right table
if (tableView == self.recipesTable) {
static NSString *recipeCellIdentifier = @"RecipeCellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:recipeCellIdentifier];
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"RecipeCell" owner:self options:nil];
if(nib.count > 0)
{
cell = self.customCell;
}
else
{
NSLog(@"Failed to load CustomCell nib file!");
}
}
// Set a number of properties of the custom cell
// ...
return cell;
self.customCell
是一個IBOutlet UITableViewCell中正在使用的文件的所有者(筆尖只包含的UITableViewCell)綁定到實際筆尖文件中的單元格。
對我而言,這表明筆尖不能及時加載,即直到視圖第一次出現之後。
我試圖筆尖裝載移動到viewDidLoad
方法,以及迫使reloadData
和setNeedsDisplay
在viewWillAppear:
結束,但也沒有用。
讓我感到困惑的是,只要具有自定義單元格的表格最初不可見,但在啓動後切換到該表格,它就會工作。