菜鸟教程小白 发表于 2022-12-12 10:30:58

用于 uinavigationcontroller 的 iOS 开源智能 Controller 推送/弹出库?


                                            <p><p>我有一个应用程序,用户可以在其中无限深入地推送 View (推送到导航堆栈)。在某些时候,会出现内存警告。我想从导航 Controller 中删除 ViewController 并释放它们。如果用户回到那些 ViewController ,我想重新创建 ViewController 并将它们推回堆栈中的正确位置。</p>

<p>这是思考这个问题的正确方法吗?</p>

<p>是否有一个开源项目可以做到这一点?这似乎不是一个不常见的问题,我宁愿不重新发明轮子。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>曾几何时,您需要确保对 <code>viewDidLoad</code> 和 <code>viewDidUnload</code> 的调用正确匹配,以便以这种方式处理内存警告。从 iOS 6 开始,这不再需要。</p>

<p>正如 <code>viewDidUnload</code> 的文档中所说:</p>

<blockquote>
<p>In iOS 5 and earlier, when a low-memory condition occurred and the
current view controller’s views were not needed, the system could opt
to call this method after the view controller’s view had been
released. This method was your chance to perform any final cleanup. If
your view controller stored separate references to the view or its
subviews, you could use this method to release those references. You
could also use this method to remove references to any objects that
you created to support the view but that are no longer needed now that
the view is gone. You would not use this method to release user data
or any other information that cannot be easily recreated.</p>

<p>In iOS 6 and later, clearing references to views and other objects in
your view controller is unnecessary.</p>
</blockquote>

<p>如果您手动将大型对象保存在内存中,例如图像或视频数据,那么您可以覆盖 <code>didReceiveMemoryWarning</code> 以在必要时释放这些对象。</p></p>
                                   
                                                <p style="font-size: 20px;">关于用于 uinavigationcontroller 的 iOS 开源智能 Controller 推送/弹出库?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/24373489/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/24373489/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: 用于 uinavigationcontroller 的 iOS 开源智能 Controller 推送/弹出库?