- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我知道有很多与此相关的问题,但我无法链接到我的问题。在我的应用程序中,我正在获取附近的餐厅,最初,如果用户单击“附近”按钮,我会使用下面的代码获取纬度、经度、地标详细信息。
-(void)setUpUserLocation
{
BOOL locationAllowed = [CLLocationManager locationServicesEnabled];
if (locationAllowed==NO)
{
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"No authorization"
message:@"Please, enable access to your location"
delegate:self cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Open Settings", nil];
[alertView show];
}
else
{
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[locationManager requestWhenInUseAuthorization];
}
}
[locationManager startUpdatingLocation];
}
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation *location=[locations lastObject];
CLGeocoder *geocoder=[[CLGeocoder alloc]init];
[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
CLPlacemark *placemark = placemarks[0];
NSDictionary *addressDictionary = [placemark addressDictionary];
}];
[self stopSignificantChangesUpdates];
}
- (void)stopSignificantChangesUpdates
{
[locationManager stopUpdatingLocation];
locationManager = nil;
}
我的问题是,如果用户位置发生变化,我该如何向用户发出警告,例如 您的位置已更改,您需要更新它,然后您才能获得附近的餐厅
Location一旦用户位置发生变化,弹出窗口就应该出现
,否则不想每次都调用 didUpdateLocation
。我调用了 startMonitoringSignificantLocationChanges
然后它没有在第一次调用 didUpdateLocation 本身。对此有任何帮助。
最佳答案
一段时间后检查或在用户移动后检查(任何你想要的),如果条件为真则调用服务...
我觉得对你有帮助;
第一步
(void)viewDidLoad {
[super viewDidLoad];
locationManager = [[CLLocationManager alloc] init];
//set the amount of metres travelled before location update is made
[locationManager setDistanceFilter:100];
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
[locationManager requestAlwaysAuthorization];
// call the timer with 5 minutes cap using 5 * 60 = 300
[NSTimer scheduledTimerWithTimeInterval:300.0f target:self selector:@selector(sendlocation1) userInfo:nil repeats:YES];
第 2 步
每 100 米更换设备此方法称为:
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
NSLog(@"%f",newLocation.coordinate.latitude);
NSLog(@"%f",newLocation.coordinate.longitude);
CLLocationDistance meters = [newLocation distanceFromLocation:oldLocation];
if(meters >=100)
{
// call webservice for location is updated
[self sendlocation1];
}else
{
// call normal method
}
}
关于ios - 位置更新问题 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37628022/
所以我的问题是我希望我的文本显示在页面的死 Angular 。我一直在尝试手动对齐它,但这似乎是一种糟糕的做法。我想要它,这样即使网页被调整为更小或者用户使用的是更小的屏幕,无序列表也会显示在屏幕的死
所以基本上,我有这段代码,它选择一个下拉菜单选项,然后按下它。我需要它按第一个选项,然后按第二个选项。 var x = document.getElementById("product-select"
我编写了我的第一个 C 程序。它去除 C 注释 ('//')。我将一个字符串传递给函数 strip_comments,创建一个与参数字符串大小相同的新字符串,然后我逐个复制一个字符,忽略注释。 这是代
我在运行下面代码中提到的清理名称实用程序时收到运行时错误 7 错误。我使用的是 512 GB 硬盘、8 GB RAM、I7 处理器,所以不应该是内存问题,但问题仍然会出现。 我的工作簿有 123188
我知道很多人都会问有关插件和回调的问题(我已经阅读了很多内容 - 这就是我到目前为止的方式),所以请耐心等待。我尝试了一个非常简单的隐藏/显示 Accordion 类型插件来解决常见问题,并成功地让它
请原谅我,如果之前已经介绍过,我搜索无济于事。 我有一个脚本可以查看目录以找到其中的文件。有一个条件行只查找具有特定扩展名的文件: if(strtolower(substr($file, -3)) =
使用链接列表扩展哈希表时会出现一些错误和警告。我想确保以下代码是正确的(扩展函数)并找出引发这些警告/错误的原因 编辑:感谢@nos,他注意到我的原型(prototype)缺少我提到的警告+错误。不幸
我已经搜索了网络,并且共识似乎是将$ {SDK_DIR}/usr/lib/libxml2添加到“Header Search Paths”中。我已经完成了此操作,并且可以在项目检查器中看到它扩展了,以更
很抱歉新手。 我想在 LinearLayout(垂直)中创建一个 View 元素列表。我创建了一个名为“category_list.xml”的 TableLayout 的 xml 布局
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and t
全新的 Xcode 版本,除了删除大量添加空函数调用的地方外,还引入了一个有趣的问题,用一段简单的代码绘制了一条大地路径: func drawPolyline(from startLocation:
我之前的问题可以在这里找到(只是想向这个最有帮助的社区保证我不会试图垃圾邮件问题): Evaluating a postfix Expression in C 我的问题涉及评估后缀表达式。假设我有一个
嘿嘿 我的声纳kotlin插件已启动并正在运行。我的RuleDefinitions放置在“规则”页面上,但是在分析某些Kotlin项目时,不会保存发现的问题。 我的传感器问题添加代码如下所示: pri
这是我在这里发表的第一篇文章。我是初学者。我正在开发一个 Spring Boot 应用程序。尝试了很多解决方案后,问题都没有得到解决。请帮忙(如果缺少任何代码片段,我会发送它。): 控制台: Erro
我是一名优秀的程序员,十分优秀!