从 iPhone 加载 URL 之前执行代码
如果你调用:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://test.com"]];
它似乎会自动退出你的应用程序——绕过 dealloc、viewDidDisappear 或任何其他函数。
有没有办法在此调用和 Safari(或电话或电子邮件)启动之间放置任何代码,而不必在每次 openURL 调用之前放置计时器?
====
编辑:仅当一个特定视图关闭时我才需要调用某些东西 - 无论它是“礼貌地”关闭还是突然关闭......
If you call:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://test.com"]];
it seems to automatically quit your app -- bypassing the dealloc, viewDidDisappear, or any other functions.
Is there a way to put any code between this call and the Safari (or Phone or Email) launch, without having to put a timer before every openURL call?
====
EDIT: I need to call something only if one particular view is closed -- whether it's closed "politely", or abruptly...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过
在
UIApplicationDelegate
的方法中添加一些内容?Have you tried putting something in the
method in your
UIApplicationDelegate
?为什么不放一个“启动 Safari”屏幕,做您需要做的事情,然后在您需要做的所有工作完成后调用 openURL 方法?
也就是说,由于用户也可以随时按主页按钮,因此无论如何您都应该保存数据。
Why not put up a "launching Safari" screen, do what you need to, and then call the openURL method when all the work you need to do is done?
That said, since a user can also just press the Home button at any time you should be saving data as you go anyway.