【问题标题】:xcode database with fmdbdatabase error带有 fmdbdatabase 错误的 xcode 数据库
【发布时间】:2012-08-17 04:39:24
【问题描述】:

我正在尝试开发一个简单的应用程序,该应用程序显示来自 sqlite3 数据库中的名称。

它返回一个错误:

2012-08-21 21:10:43.182 NameDatabase[1325:c07] 断言失败 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:]; /SourceCache/UIKit_Sim/UIKit-1914.84/UITableView.m:6061 2012-08-21 21:10:43.184 NameDatabase[1325:c07] 由于未捕获而终止应用程序 异常'NSInternalInconsistencyException',原因:'UITableView dataSource 必须从 tableView 返回一个单元格:cellForRowAtIndexPath:'

我已经尝试了很多方法来解决这个问题,但我没有想法。

这是我认为导致问题的方法:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"CustomerCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    NameClass *name_class = [self.name_vc objectAtIndex:[indexPath row]];
    cell.textLabel.text = name_class.name;
    //[[cell textLabel] setText:[NSString stringWithFormat:@"%@ ,@%d",name_class.name, name_class.id]];
    return cell;
}

【问题讨论】:

标签: objective-c xcode uitableview fmdb


【解决方案1】:

您需要分配 tableViewCell 以防 dequeueReusableCellWithIdentifier:CellIdentifier 没有为您提供非零值

    if (!cell) {
    cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}

【讨论】:

  • 好的,谢谢,现在至少窗口是可见的.. 但什么也没有出现?
  • 现在它说:2012-08-21 21:30:34.003 NameDatabase[1516:c07] -[NSObject tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x6c45420 2012-08-21 21 :30:34.004 NameDatabase [1516:c07] ***由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'-[NSObject tableView:numberOfRowsInSection:]:无法识别的选择器发送到实例0x6c45420'
  • 确保为 tableview 分配了正确的委托。似乎有人在不应该收到委托回调时收到了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-09
  • 2012-10-17
  • 1970-01-01
  • 1970-01-01
  • 2022-08-10
  • 2018-12-11
相关资源
最近更新 更多