【问题标题】:which is the delegate method for don't allow tap in "App would like to use your current location"?在“应用程序想使用您当前的位置”中不允许点击的委托方法是什么?
【发布时间】:2013-02-08 06:10:12
【问题描述】:

我想在用户按下“不允许”时打开一个弹出窗口“应用程序想使用您当前的位置”。有什么委托方法吗??

【问题讨论】:

标签: iphone ios objective-c geolocation


【解决方案1】:

Don't you dare reading the documentation...

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
    if (status == kCLAuthorizationStatusDenied) {
        // FA1LZ
    }
}

【讨论】:

  • 呵呵.. :) 非常感谢.. :)
【解决方案2】:

检查locationManager:didFailWithError:locationManager:didChangeAuthorizationStatus:CLLocationManagerDelegate

【讨论】:

    【解决方案3】:

    首先需要获取当前位置。阅读此documentation 以获取当前位置。

    并使用这个方法

    - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
    

    参数:

    1 - 经理
    报告事件的位置管理器对象。
    2 - 状态
    应用程序的新授权状态。

    此方法的使用

    只要应用程序使用位置服务的能力发生变化,就会调用此方法。由于用户允许或拒绝为您的应用程序或整个系统使用定位服务,因此可能会发生更改。

    更多信息请阅读official document

    【讨论】:

      【解决方案4】:

      您可以使用以下委托方法:

      - (void)locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)error
      {
          if([error code]== kCLErrorDenied)
              self.locationDenied = YES;
      
              switch ([error code]) {
                  // "Don't Allow" on two successive app launches is the same as saying "never allow". The user
                  // can reset this for all apps by going to Settings > General > Reset > Reset Location Warnings.
              case kCLErrorDenied:
                  [appDelegate showAllowGPSLocationView];
              default:
                  break;
              }
      
          self.locationDefined = NO;
      }
      

      当用户不允许 GPS 定位时,将调用上述委托方法。您可以使用“kCLErrorDenied”检查并处理您想做的任何事情。

      这里,“showAllowGPSLocationView”是“AppDelegate”中实现的方法,用于通知用户允许GPS定位。

      希望对你有所帮助。

      快乐编码:)

      干杯!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-04-14
        • 1970-01-01
        • 2022-01-15
        • 1970-01-01
        • 2014-10-05
        • 2013-03-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多