在应用程序委托中弹出到根视图控制器 [英] Pop to root view controller in app delegate

查看:56
本文介绍了在应用程序委托中弹出到根视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以登录的应用程序,如果将其发送到后台超过10分钟后又启动了该应用程序,我会弹出一个不错的会话已过期"警报,并将其发送到根视图控制器(登录页面) .

I have an app that someone logs into and if they launch it after sending it to the background for more than 10 minutes I pop up a nice little "session expired" alert and send them to the root view controller (login page).

一切正常,但我不知道如何从应用程序委托的applicationWillEnterForeground:方法弹出到导航控制器堆栈中的根视图控制器.

Everything works great but I don't know how to pop to the root view controller in my navigation controller stack from the app delegate's applicationWillEnterForeground: method.

我尝试将navigationController保存到appDelegate变量中,但是我想知道应用程序是否在后台运行了好几天,是否iOS开始释放某些变量,因为当时我在此方法中遇到错误.

I tried saving off the navigationController onto an appDelegate variable but I wonder if the app is in the background for several days, if iOS starts freeing some variables, as I get an error in this method at that time.

有什么想法吗?

推荐答案

如果导航控制器是应用程序的根视图控制器,则可以像以下方式获得它:

If the navigation controller is your application's root view controller, then you can get it like:

UINavigationController *myNavCon = (UINavigationController*)self.window.rootViewController;

其中self在应用程序委托中

这篇关于在应用程序委托中弹出到根视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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