gpt4 book ai didi

IOS 内存错误,而 DELETE 按钮显示在 TableView 上

转载 作者:行者123 更新时间:2023-12-01 16:42:48 25 4
gpt4 key购买 nike

我在使用 TableView 处理项目时收到内存错误。

我在一个新项目上复制了 Storyboard并收到了同样的错误。

这是 Storyboard布局:

01 - The Storyboard

如果在显示删除按钮时按下“返回”按钮,则会出现如下内存错误:

02 - Running app and Memory error

用于删除的代码是:

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return YES;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{

// Remove the row from data model
[tableData removeObjectAtIndex:indexPath.row];

// Request table view to reload
[tableView reloadData];

}

我发布这个问题是为了了解更多关于 Xcode 和 Objective-C 的信息。
  • 有没有人经历过类似的事情?
  • 我应该遵循什么过程来调试此错误?
  • 是否有 Apple 程序来报告此类错误?
  • 最佳答案

    这似乎是一个错误。使用 Instruments,我发现 _canEditRowAtIndexPath: 消息被发送到 CDUTableViewController 的已释放实例(在通过点击后退按钮从堆栈中弹出之后)。当表在 UITableViewController 而不是 UIViewController 中时,永远不会发送此消息——我不知道为什么会这样。

    您可以通过使用 UITableViewController 或通过在 CDUViewController 中为 CDUTableViewController 创建一个强大的属性并插入代码而不是使用 segue 来解决该问题(这样您的 CDUTableViewController 不会在弹出时释放)。

    关于IOS 内存错误,而 DELETE 按钮显示在 TableView 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22773929/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com