【问题标题】:No visible @interface for UITableView when deleting a row删除行时 UITableView 没有可见的@interface
【发布时间】:2013-01-09 11:59:36
【问题描述】:

我知道以前在 SO 上已经问过这类问题,我几乎尝试了所有这些问题,但都无济于事。我正在尝试从 UITableView 中删除一行。这是我的代码。

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        //calls to a method that deletes the row from the backend SQLite database
        [self deleteCompany:indexPath.row];

        //theCompanies is a NSMutableArray. When the app starts, it retrieves the data and display it in the UITableView
        [theCompanies removeObjectAtIndex:indexPath.row];

        //Below line is where the error occurs. 
        [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
                         withRowAnimation:YES
              UITableViewRowAnimationFade:UITableViewRowAnimationFade];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {

    }   
}

我在构建应用程序时收到以下编译器错误。

“UITableView”没有可见的@interface 声明选择器...

我不知道接下来我应该做什么。任何帮助将不胜感激。

谢谢。

【问题讨论】:

  • 错误消息的下一部分是什么。你遗漏了重要的部分:-)
  • 你为什么不顺便阅读一下文档呢?此外,这太基础了——你甚至不知道调用方法的正确语法。
  • @H2CO3 我假设你是反对者。也许它对你来说太基础了。但我几周前才开始 iOS 开发。

标签: ios uitableview ios5 delete-row


【解决方案1】:

方法是这样的

- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation

有两个参数见这里Apple UITableView Document

但是你使用了 like is is is 的三个参数和 withRowAnimation 作为 BOOL 但它不是 BOOL。

试试这样的:

[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

【讨论】:

    【解决方案2】:

    改变这一行:

    [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
                             withRowAnimation:YES
                  UITableViewRowAnimationFade:UITableViewRowAnimationFade];
    

    [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
                             withRowAnimation:UITableViewRowAnimationFade];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-07
      • 2015-05-17
      • 1970-01-01
      • 2017-10-13
      相关资源
      最近更新 更多