为什么“现在模态视图控制器”? [英] why "present modal view controller"?

查看:121
本文介绍了为什么“现在模态视图控制器”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想了解模式视图控制器的使用。什么时候和为什么要使用它们?有指南吗?

Just curious about the modal view controller usage. When and why should we use them? Is there a guideline?

我发现示例核心数据库代码创建了一个导航控制器,只是为了呈现模态视图控制器。为什么呢?

I found the sample core data book code create a navigation controller just to present a modal view controller. Why is that?

   UINavigationController *navController = [[UINavigationController alloc] 
                                                 initWithRootViewController:addViewController];

    [self.navigationController presentModalViewController:navController 
                               animated:YES];

这是否有功能的原因?如果我们只是将addViewController推送到self.navigationController,它会工作吗?

Is there a functional reason to this? Would it work if we just push the addViewController to self.navigationController?

推荐答案

通常你使用模式视图控制器来集中用户的注意力任务。当你推,用户是在某种导航流,但仍然有他们的指尖的总应用程序。他们可能决定前进或后退,切换到中间不同的选项卡,无论什么。当他们得到一个模式视图控制器,他们不能做任何,直到任务完成或取消(模态视图被关闭)。

Generally you use modal view controllers to focus the user's attention on a Task. When you push, the user is in some kind of navigation flow, but still has the total application at their fingertips. They might decide to go forward or backward, switch to a different tab in the middle, whatever. When they get a modal view controller, they can't do any of that until the task is completed or canceled out of (the modal view is dismissed).

为什么此代码使用presentModalViewController? (不是pushViewController)

这篇关于为什么“现在模态视图控制器”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆