当我的 iPhone 应用程序进入前台时,我想运行一些 JavaScript 代码。所以我这样做了:
- (void)applicationWillEnterForeground:(UIApplication *)application {
NSLog(@"1");
[self.viewController.webView stringByEvaluatingJavaScriptFromString:@"window.alert('ok');"];
NSLog(@"2");
}
当我运行它并将应用程序从后台切换到前台时,日志只显示“1”而不是“2”,并且我没有收到任何警报消息。
这是怎么回事?
ps.:我用的是Phonegap。