iOS4中的App代理和View Controller [英] App delegate and View Controller in iOS4

查看:146
本文介绍了iOS4中的App代理和View Controller的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS4中,使用多任务功能,首页按钮会将应用置于背景中,而当它返回到前台时,我希望View Controller刷新(因此ViewWillAppear被调用)。我把它放在应用程序委托中,认为这应该可以工作,但没有任何反应。

   - (void)applicationDidFinishLaunching:(UIApplication *)application { 

//
[window addSubview:viewController.view];
[window makeKeyAndVisible];
}


- (void)applicationWillEnterForeground:(UIApplication *)应用程序{
[viewController.view reloadInputViews];
}

任何人都可以帮助我强制视图控制器执行/刷新它已经显示?

解决方案

您可以明确调用viewWillAppear,例如

   - (void)applicationWillEnterForeground:(UIApplication *)application {
[viewController.view reloadInputViews];

[viewController viewWillAppear];
}


With multi-tasking in iOS4, the home button puts the app into background and when it comes back into foreground I want the View Controller to 'refresh' (and hence viewWillAppear to be called). I put this in the app delegate thought this should work but nothing happens

 - (void)applicationDidFinishLaunching:(UIApplication *)application {    

    //  
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
 }


 - (void)applicationWillEnterForeground:(UIApplication *)application {
    [viewController.view reloadInputViews];
 }

Can anyone help me with forcing a view controller to 'execute'/refresh when it is already showing?

解决方案

You could call viewWillAppear explicitly e.g.

- (void)applicationWillEnterForeground:(UIApplication *)application {
    [viewController.view reloadInputViews];

    [viewController viewWillAppear];
 }

这篇关于iOS4中的App代理和View Controller的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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