iOS - 如何检测 UIWebView 上的会话超时
我有一个 UIWebView 显示一个具有超时策略(空闲 1800 秒)的网站。 由于我使用自定义登录视图连接到网站,因此我想在网站发出超时警报后调用相同的自定义视图。
我怎样才能检测到这样的警报已发送到网络视图,以便我可以从那里调用我的代码?
感谢您的帮助。
I have a UIWebView displaying a website that has a timeout policy (idle for 1800 seconds).
Since I use a custom login view to connect to the site, I want to call this same custom view after the website has issued the timeout alert.
How can I detect that such an alert has been issued to the webview, so I can call my code from there?
Thank you for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果网站在超时时重定向到特定页面,您可以在 UIWebViewDelegate 的
webView:shouldStartLoadWithRequest:navigationType:
方法中观察该页面是否加载。If the website redirects to a particular page on timeout, you could watch for that page to be loaded in your UIWebViewDelegate's
webView:shouldStartLoadWithRequest:navigationType:
method.不知道如何从 UIKit 角度解决这个问题,但如果您的会话超时已知,您可以在其中一个控制器中创建一个 NSTimer 来在定义的经过时间时提醒您,并在每次应用程序调用您的站点时重置它。
Don't know how to solve this from UIKit perspective but if your session time out is known you could create an NSTimer in one of your controllers to alert you when a defined elapsed time, resetting it each time the app calls your site.