当用户启动模态视图控制器后从跳板返回时,会调用什么方法?
这个问题与这个问题非常相似,有一个例外。我没有使用普通的导航控制器启动我的默认视图控制器,而是添加了一个附加的视图控制器,它只是一个启动页面,允许我显示加载对话框/等
在主视图控制器的“viewDidLoad”中我启动了这个像这样使用“presentModalViewController”
- (void)viewDidLoad
{
SplashPage *splashScreen = [[[SplashPage alloc] initWithNibName:@"SplashPage" bundle:nil viewControllerObj:self] autorelease];
[self presentModalViewController:splashScreen animated:NO];
[super viewDidLoad];
}
然后在我的启动视图中我做了一些事情(第一个是基本的连接检查,以确保应用程序可以访问互联网)。
第一次启动应用程序时,我在现在活动的启动视图控制器的 viewDidLoad 内进行此检查(就像这样)
- (void)viewDidLoad
{
[super viewDidLoad];
[self.viewController invokeConnectivityCheck];
}
问题是这样的 - 当此失败并且用户“卡在”加载屏幕预启动时(基本上) )当它们从跳板返回时,在此启动视图控制器中调用什么方法(此处支持多任务处理)?
我已尝试以下操作,但当我关闭应用程序并返回时,每个操作都没有触发
- applicationWillEnterForeground
- didFinishLaunchingWithOptions
- applicationDidBecomeActive
我在这里缺少什么是 iOS5 友好的?或者,由于我在这里使用的模态方法,是否会调用主/默认视图控制器而不是启动画面?
先感谢您
This question is very similar to this one, with one exception. Instead of having a normal navigation controller launching my default view controller, I've added an additional view controller that is simply a splash page that allows me to show a loading dialog / etc
In my "viewDidLoad" of the main view controller I launch this using "presentModalViewController" like so
- (void)viewDidLoad
{
SplashPage *splashScreen = [[[SplashPage alloc] initWithNibName:@"SplashPage" bundle:nil viewControllerObj:self] autorelease];
[self presentModalViewController:splashScreen animated:NO];
[super viewDidLoad];
}
Then inside my splash view I do a few things (the first is a basic connectivity check to ensure the app has internet access for example).
And the first time the app is launched I do this check inside the viewDidLoad of the now active splash view controller (like so)
- (void)viewDidLoad
{
[super viewDidLoad];
[self.viewController invokeConnectivityCheck];
}
The problem is this- when this fails and the user is "stuck" at a loading screen pre-launch (basically) what method is invoked in this splash view controller when they come back from the springboard (multitasking supported here)?
I've tried the following but each did not fire when I close the app and come back
- applicationWillEnterForeground
- didFinishLaunchingWithOptions
- applicationDidBecomeActive
What am I missing here that is iOS5 friendly? Or does the main/default view controller get invoked instead of the splash because of the modal approach I'm using here?
Thank you in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当你“从跳板回来”时,
appliationDidBecomeActive
肯定会被调用。文件:
appliationDidBecomeActive
will certainly be called when you are "coming back from the springboard".Docs:
因此,看起来我使用的模式不适合导航控制器驱动(通过 appDelegate)风格的 iPhone 应用程序,因此我没有让默认/主视图控制器在 viewDidLoad 方法中处理此模式,而是将此逻辑推到了appDelegate 本身,因此它不是每个视图控制器的直接责任。
如果您打算做这样的事情,我会在 appDelegates 中调用它吗?使用当前活动视图控制器的方法(基本上我在 appDelegate 中保留状态,以便它知道视图控制器处于焦点)
另一个要求是在 appDelegate 中回调以关闭模式,就像这样
希望这对其他人有帮助(并不是说它直接回答了问题)-如果有人有一个合法的答案,我会对此给予认可,因为这主要是为了历史/对所使用模式的另一种看法。
So it looks like the pattern I was using didn't lend itself to the navigation controller driven (via appDelegate) style iPhone app so instead of having the default/main view controller handle this modal in the viewDidLoad method I pushed this logic off to the appDelegate itself so it's not a responsibility of each view controller directly.
If you plan to do something like this I invoke this inside the appDelegates ? method using the currently active view controller (basically I keep state in the appDelegate so it's aware of the view controller in focus)
The other requirement of this is a call back in the appDelegate to close the modal like so
Hope this was helpful to someone else (not that it directly answered the question) -if someone has a legit answer I'll give credit for that as this was mostly for history / another take on the pattern used.