CLLocationManager:didEnterRegion& didExitRegionAlert方法没有调用

时间:2016-09-13 05:37:45

标签: iphone location cllocationmanager geofencing clregion

我正在使用 CLRegion 进行地理围栏。我监控 notifyOnExit notifyOnEntry CLCircularRegion 设置。 这是我的代码:

private bool GetSource(ISymbol symbol, out string filePath)
{
    var baseLocation = symbol.Locations.FirstOrDefault();
    filePath = "SPECIFY CURRENT SYNTAX TREE FILE PATH";

    if (baseLocation == null)
        return false;

    var baseLocationPath = baseLocation.ToString();

    if (baseLocationPath.Contains("SourceFile("))
    {
        baseLocationPath = baseLocation.ToString().Replace("SourceFile(", "");
        filePath = baseLocationPath.Substring(0, baseLocationPath.LastIndexOf("[", StringComparison.Ordinal));
    }
    else if (baseLocationPath.Contains("MetadataFile("))
    {
        baseLocationPath = baseLocation.ToString().Replace("MetadataFile(", "");
        filePath = baseLocationPath.Substring(0, baseLocationPath.LastIndexOf(".dll", StringComparison.Ordinal) + 4);
    }

    return baseLocation.IsInSource;
}

在监控区域之前,我尝试去除所有区域之前的区域。然后我用区域监控。但它会直接启用 带 monitoringDidFailForRegion 委托方法错误:无法完成操作。 (kCLErrorDomain错误4。)错误。并且它不会被称为委托方法。

 CLLocationCoordinate2D coordinateGYM = CLLocationCoordinate2DMake(lat,lng);
    CLCircularRegion *regionSet = [[CLCircularRegion alloc]initWithCenter:coordinateGYM radius:RADIUS identifier:strTitle];
    if(isExit)
    {
        regionSet.notifyOnExit = YES;
        regionSet.notifyOnEntry = NO;
    }
    else
    {
        regionSet.notifyOnExit = NO;
        regionSet.notifyOnEntry = YES;
    }
    [self.locationManager startMonitoringForRegion:regionSet];
    [self.locationManager startUpdatingHeading];

任何人都可以帮我解决代码中的错误吗? 谢谢,

0 个答案:

没有答案