从 iPhone 加载 URL 之前执行代码

发布于 2024-08-23 07:00:06 字数 331 浏览 6 评论 0原文

如果你调用:

[[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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

您是否尝试过

- (void)applicationWillTerminate:(UIApplication *)application

UIApplicationDelegate 的方法中添加一些内容?

Have you tried putting something in the

- (void)applicationWillTerminate:(UIApplication *)application

method in your UIApplicationDelegate?

如此安好 2024-08-30 07:00:06

为什么不放一个“启动 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文