1
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSString *currentNames = [nameKeys objectAtIndex:indexPath.row];
[cell.textLabel setText:currentNames];
return cell;
}
爲什麼我得到低於錯誤(我正在使用.XIB
而不是故事板iOS 6和Xcode 4.5)。 我確實已經連接datasource
並從連接檢查器或文件所有者處委託。如何在iOS 6和xcode 4.5中使用.xib或nib來製作簡單的表格視圖?
錯誤:
Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2372/UITableView.m:4460
2012-12-27 11:35:45.146 TableViewWithXib[570:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
看看你的視圖Controller是從哪個類繼承的?即。在.h文件中的這種行'@interface YOURCLASSNAME:UIViewController' –
是的,我已經確認了的協議,但錯誤仍然相同 –
然後,你必須有一個'@property強,非原子)IBOutlet UITableView * tableView;'定義的屬性,也在.XIB中連接到'UITableView'實例。然後它不會給出任何錯誤,因爲它從不給我任何錯誤。 –