菜鸟教程小白 发表于 2022-12-13 05:53:45

objective-c - 模态视图 Controller 是替代 iPad 上整个界面的首选方式吗?


                                            <p><p>具体来说,我有一个类似游戏的东西,它的菜单屏幕由标准组件组成。我想要一个按钮切换到另一个 ViewController ,用户将与之交互一段时间,然后返回菜单屏幕。似乎让菜单 Controller 将“游戏”模式呈现为模态视图 Controller 是最直接的解决方案,但这是从本质上替换整个 View 的最佳方式吗?只要模态 Controller 在前面,整个菜单(以后可能会成为深度导航或拆分 Controller )是否保存在内存中,这是我应该担心的事情吗?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>这个问题实际上有两个部分:</p>
<p>在 iPad 应用程序中从一个 View 转换到下一个 View 的哪种方法可以为用户提供最佳体验?</p>
<p>从一个 View 转换到下一个 View 的哪种方法最容易实现并且最好地处理内存管理?</p>
<p>除了向您指出 Apple 的“iPad 人机界面指南”(除其他事项外)外,我不会尝试解决此问题的第一部分:</p>
<blockquote>
<p><strong>Reduce Full-Screen Transitions</strong></p>
<p>Closely associate visual transitions with the content that’s changing. Instead of swapping in a whole new screen when some embedded information changes, try to update only the areas of the user interface that need it. As a general rule, prefer transitioning individual views and objects, not the screen. In most cases, flipping the entire screen is not recommended.</p>
<p>When you perform fewer full-screen transitions, your application has greater visual stability, which helps people keep track of where they are in their task. You can use UI elements such as split view and popover to lessen the need for full-screen transitions.</p>
</blockquote>
<p> <a href="http://developer.apple.com/library/ios/prerelease/#documentation/General/Conceptual/iPadHIG/DesignGuidelines/DesignGuidelines.html" rel="noreferrer noopener nofollow">http://developer.apple.com/library/ios/prerelease/#documentation/General/Conceptual/iPadHIG/DesignGuidelines/DesignGuidelines.html</a> </p>
<p>但是,在您的情况下,我认为全屏转换是完全合适的(但我不是用户体验专家)。</p>
<p>在回答第二部分时,是的,以模态方式显示新的 ViewController 似乎是一个不错的方法。</p>
<p>默认情况下,菜单 View 使用的对象和模态视图使用的对象都将保存在内存中——但是使用 UIViewController 子类的好处是它们内置了一些默认的内存管理。如果您的应用程序在全屏模式下显示模态视图时收到内存警告,则菜单 ViewController 的 View 将被删除,并且将调用它的“viewDidUnload”方法。所以在你实现这个方法时,你应该释放你不需要的任何对象,然后在菜单 ViewController 的 viewDidLoad 方法中根据需要重新创建它们(在显示菜单 View 之前将再次调用该方法)。</p>
<p>这在 UIViewController 类引用中有更详细的解释:</p>
<blockquote>
<p>When a low-memory warning occurs, the UIViewController class purges its views if it knows it can reload or recreate them again later. If this happens, it also calls the viewDidUnload method to give your code a chance to relinquish ownership of any objects that are associated with your view hierarchy, including objects loaded with the nib file, objects created in your viewDidLoad method, and objects created lazily at runtime and added to the view hierarchy. Typically, if your view controller contains outlets (properties or raw variables that contain the IBOutlet keyword), you should use the viewDidUnload method to relinquish ownership of those outlets or any other view-related data that you no longer need.</p>
</blockquote>
<p> <a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html" rel="noreferrer noopener nofollow">http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html</a> </p></p>
                                   
                                                <p style="font-size: 20px;">关于objective-c - 模态视图 Controller 是替代 iPad 上整个界面的首选方式吗?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/3623405/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/3623405/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: objective-c - 模态视图 Controller 是替代 iPad 上整个界面的首选方式吗?