gpt4 book ai didi

ios - UIApplication sharedApplication 在返回应用程序并重新启动时继续执行

转载 作者:可可西里 更新时间:2023-11-01 06:16:11 25 4
gpt4 key购买 nike

下面的代码工作正常,但是当我回到我的应用程序时,它继续执行下面的代码,但我不知道为什么以及如何停止它。我认为这只发生在 ios5.0 中:应用流程 - rootviewcontroller -> mainviewcontroller ->webview

下面的代码在mainviewcontroller的webview的shouldstartloadrequest方法中调用

@property (readwrite, retain) UIWebView *_loginWebView;
...
..
- (void)viewDidLoad
{
[super viewDidLoad];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[_loginWebView loadRequest:requestObj];
}

//每当 webview 收到打开 url 的请求时调用以下内容

   - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
//return no is a special case there is more code in the method which I am not showing here
if ([[UIApplication sharedApplication] canOpenURL:myURL])
{
[[UIApplication sharedApplication] openURL:myURL];
}
else
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:newPath]];
}
return NO;
}
//above is a special case

}

head标签内容-

<head>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<!-- iOS Stuff -->
<link rel="apple-touch-icon" href="images/...."/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="shortcut icon" href="favicon.ico" />
<script async="async" src="https://......."></script>
<script type="text/javascript">
..........
</script>
</head>

最佳答案

myURL 是否在 header 中设置了元刷新?如果网页正在重新加载,将调用此方法。如果有重定向,它也会被调用。

关于ios - UIApplication sharedApplication 在返回应用程序并重新启动时继续执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14342480/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com