从应用程序委托不工作重新加载webview

问题描述:

我想在我的应用程序到达前台时在我的视图控制器中重新加载webview。我在我的应用程序代理的-applicationWillEnterForeground-applicationDidBecomeActive方法中创建了一个视图控制器对象。但我无法刷新我的webview。从应用程序委托不工作重新加载webview

+1

显示你的代码'applicationDidBecomeActive'和'applicationwillEnterForeground'。 – 2013-04-04 06:56:07

+0

MainViewController * mainViewCtrler = [[MainViewController alloc] init]; [mainViewCtrler connectToServer];我已经在connectToServer方法中重新加载了web视图。 – nikBhosale 2013-04-04 08:02:31

applicationWillEnterForeground可能不是最好的办法。

在包含web视图添加通知方法如下面

[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(didEnterForeground) 
name:UIApplicationWillEnterForegroundNotification 
object:nil]; 

-(void) didEnterForeGround 
{ 
//[webView reload]; 
} 
+0

嗨!感谢您的回复。我也是这样做的。但仍然无法正常工作。这里是我的代码 - (id)init {[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadWebView :) name:UIApplicationWillEnterForegroundNotification object:nil]; NSLog(@“Reload webview”); 回归自我; } - (void)reloadWebView:(NSNotification *)notification { [locationServicewebView reload]; } – nikBhosale 2013-04-04 07:47:52

+0

通知生成正确给一些NSLog那里和测试或尝试重新加载webView在viewWillAppear。 – satheeshwaran 2013-04-04 07:49:42

当应用程序涉及到前景类是应用程序是活动状态,在上viewDidLoad中或特定视图控制器viewdidAppear方法[网页视图ReloadData];多数民众赞成它,你不愿意做任何东西在appdelegate类