菜鸟教程小白 发表于 2022-12-13 09:28:50

objective-c - 取消选择RowAtIndexPath : failing in iOS5


                                            <p><p>以下在 iOS 4.3 中运行良好,但在 iOS5 中抛出 EXC_BAD_ACCESS。</p>

<pre><code>if(mainTable != nil){
    ;
</code></pre>

<p>mainTable 是 UITableView 类型。它在带有 deselectRowAtIndexPath: 的行上失败。离开主(第一个) TableView 时会发生上述异常。步骤是: 在主 TableView 中单击一行。另一个 TableView 显示。单击左上角按钮返回主表并发生异常。</p>

<p>其实到时候</p>

<pre><code> - (void)viewDidDisappear:(BOOL)animated
</code></pre>

<p>被断点命中,currentIndexPath 已在 iOS5 中发布。</p>

<p>我可以在这里寻找什么?我知道 iOS5 在释放对象方面做了一些不同的事情。也许我可以做一些额外的检查,但我不确定从哪里开始。</p>

<p>编辑:
它被定义为</p>

<pre><code>currentCellIndex = indexPath;   
</code></pre>

<p>来自</p>

<pre><code>-(void) displaySubView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath
</code></pre>

<p>我确实在我的方案的运行部分启用了僵尸,现在获取详细信息。当我点击上述行时,我在控制台中看到:</p>

<pre><code>*** -: message sent to deallocated instance 0x85a2010
</code></pre>

<p>为什么在 iOS5 而不是 iOS 4.3 中会发生这种情况?我在 currentIndexPath 的 dealloc 中确实有一个断点,并且它永远不会被命中。</p>

<p>我开始相信这与 ARC 有关。我仍然有很多保留/释放。我不想为 ARC 做自动格式化,因为那会导致更多问题。我确实尝试了用于在每个文件的基础上禁用 ARC 的标志。这只是用未知命令引发了编译器错误。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>这不是您问题的确切答案,但您可能需要考虑取消选择 <code>viewWillAppear</code> 中的行:</p>

<pre><code>-(void)viewWillAppear:(BOOL)animated {
    ;
    animated:YES];
}
</code></pre>

<p>您需要在“父” ViewController 中实现这一点,其中声明了 <code>mainTable</code>。</p>

<p>关于您的实际问题,您能告诉我们您的 <code>@property</code> 是如何查找 <code>currentCellIndex</code> 的吗?</p></p>
                                   
                                                <p style="font-size: 20px;">关于objective-c - 取消选择RowAtIndexPath : failing in iOS5,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/7816962/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/7816962/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: objective-c - 取消选择RowAtIndexPath : failing in iOS5