我正在使用 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];
任何人都可以帮我解决代码中的错误吗? 谢谢,