openURL 回调?

编程入门 行业动态 更新时间:2024-10-27 01:28:16
本文介绍了openURL 回调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

用户拒绝定位,我将用户发送到设置"应用上的定位设置:

User refuses location, I send user to Location settings on Settings app:

UIApplication.sharedApplication().openURL(NSURL(string:"prefs:root=LOCATION_SERVICES")!)

用户从设置"应用授权位置,返回到我的应用,左上角带有 返回应用

User authorizes location from Settings app, returns to my app with Back to App on top left

我怎么知道他回到了应用程序?viewDidAppear 不起作用

How do I know that he came back to the app? viewDidAppear doesn't work

推荐答案

您可以通过检查AppDelegate的方法轻松检测:-

You can easily detect by checking AppDelegate's method:-

func applicationWillEnterForeground(application: UIApplication!) {

或者通过NSNotificationCenter在你的视图控制器的viewDidLoad()中注册一个通知:-

Or by registering a notification in your view controller's viewDidLoad() by NSNotificationCenter:-

NSNotificationCenter.defaultCenter().addObserver(self, selector: "applicationWillEnterForeground", name: UIApplicationWillEnterForegroundNotification, object: nil)


//calling selector method
 func applicationWillEnterForeground() {
            println("did enter foreground")
        }

这篇关于openURL 回调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-29 03:26:40,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:回调   openURL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!