【问题标题】:openURL Callback?openURL 回调?
【发布时间】:2016-02-22 05:35:37
【问题描述】:

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

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

用户从“设置”应用授权位置,返回到我的应用,左上角有Back to App

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

【问题讨论】:

  • 发生了什么?...
  • 你找到解决办法了吗?,你可以回答这个问题

标签: ios swift uikit segue


【解决方案1】:

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

func applicationWillEnterForeground(application: UIApplication!) {

或者通过NSNotificationCenter:-

在视图控制器的 viewDidLoad() 中注册通知
NSNotificationCenter.defaultCenter().addObserver(self, selector: "applicationWillEnterForeground", name: UIApplicationWillEnterForegroundNotification, object: nil)


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

【讨论】:

    【解决方案2】:
    【解决方案3】:

    在你的 viewController 中使用 NSNotificationCenter

    在 viewDidLoad 上调用它

    - (void)registerAppEnterForeground
    {
        [[NSNotificationCenter defaultCenter]
         addObserver:self
         selector:@selector(applicationWillEnterForeground)
         name:UIApplicationWillEnterForegroundNotification
         object:nil];
    }
    
    
    -(void)applicationWillEnterForeground
    {
     /*HANDLE YOUR CODE HERE*/
    }
    

    【讨论】:

      猜你喜欢
      • 2012-04-07
      • 2023-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-19
      • 2010-12-21
      相关资源
      最近更新 更多