ios 唤醒app返回根视图_更改iOS窗口的根视图控制器

Is the root view controller of a iOS Window usually initialized once in the beginning to a tab bar controller or navigation controller? Is it okay to change the root view controller multiple times within an app?

I have a scenario where the top view is different based on user action. I was thinking of having a navigation controller with the top view controller having the image of the splash screen, and pushing/popping view controllers as required. Alternately, I can keep changing the window's top view controller. Which will be a better approach?

解决方案

It is more usual to use a "presented view controller" (presentViewController:animated:completion:). You can have as many of these as you like, effectively appearing in front of (and basically replacing) the root view controller. There doesn't have to be any animation if you don't want, or there can be. You can dismiss the presented view controller to go back to the original root view controller, but you don't have to; the presented view controller can just be there forever if you like.

Here's the section on presented view controllers from my book:

In this diagram (from earlier in that chapter), a presented view controller has completely taken over the app interface; the root view controller and its subviews are no longer in the interface. The root view controller still exists, but this is lightweight and doesn't matter.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值