我设置了以下方法:
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
Run Code Online (Sandbox Code Playgroud)
它工作正常并被调用,但它从不包含多个位置。我试图在手机移动时获取新旧位置之间的距离。我错过了什么吗?location 数组中永远不会有两个项目。
我正在尝试用 Swift 编写一个 iOS 应用程序,让用户拍照,然后我将在图像上叠加一些额外的数据。我希望图像包含位置数据。我正在使用 AVCapturePhoto,我可以在文档中看到它有一些元数据变量,但我找不到有关如何使用它们的任何信息。当我现在用我的应用拍照时,它的 EXIF 信息中没有位置数据。
如何设置捕获会话以嵌入位置数据?
我正在创建一个基于位置的应用程序,当用户拒绝位置访问时,会弹出一个警报视图,要求用户转到设置页面并更新设置以允许位置访问。如果用户允许访问然后按回,则视图不会使用允许更新位置的更新设置刷新。
是否有可以在用户从设置页面返回应用程序后运行的功能,该功能将刷新并开始更新位置。
我感谢任何建议或帮助。谢谢你。
func alertForNoLocationAccess(){
let alert = UIAlertController(title: "Allow Location Access", message: "Cannot add location data and map coordinates to your entries without access. Press settings to update or cancel to deny access.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Settings", style: .default, handler: { action in
if let url = URL(string:UIApplication.openSettingsURLString) {
if UIApplication.shared.canOpenURL(url) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
}
}
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
self.present(alert, …Run Code Online (Sandbox Code Playgroud) 我正在尝试检测用户是否正在我的应用程序中输入特定区域。
如果应用程序启动然后进入该区域时用户不在特定区域,则此方法可以正常工作。
但是,如果应用程序启动时用户位于特定区域,则不会触发“didEnterRegion”函数。
这是我的代码:
override func viewDidLoad() {
super.viewDidLoad()
self.dbRef = Database.database().reference()
self.mapView.delegate = self
self.initLocationManager()
guard let userLocation = locationManager.location?.coordinate else {return}
self.userLocation = userLocation
let region = MKCoordinateRegion(center: userLocation, latitudinalMeters: 1200, longitudinalMeters: 1200)
mapView.setRegion(region, animated: true)
self.getPlaces { (places) in
self.places = places
self.addAnnotationsToMap(places)
if(CLLocationManager.authorizationStatus() == .authorizedAlways){
if CLLocationManager.isMonitoringAvailable(for: CLCircularRegion.self){
for place in places{
self.startMonitoring(place)
}
}
}
}
}
func startMonitoring(_ place: Place){
let region = CLCircularRegion(center: place.getCoordinate(), radius: 50, identifier: place.identifier)
region.notifyOnEntry = true
region.notifyOnExit = …Run Code Online (Sandbox Code Playgroud) 我正在尝试将地图数据添加到我为 Apple Watch 应用保存的跑步和骑行记录中。我正在使用 CLLocationManager 和 HKWorkoutRouteBuilder。
苹果似乎对构建锻炼路线一个相当不错的指南在这里。但是,我对文档中的一句话感到很困惑:“特别是对于路线数据,您必须请求阅读和共享 HKWorkout 和 HKWorkoutRoute 示例的权限。”
以下是我的应用程序的当前权限。我知道我仍然需要“锻炼路线”作为一个选项出现,但我正在努力这样做。最重要的是,我不确定是否还需要获得其他权限。
非常感谢你的帮助!!-大卫
我\xe2\x80\x99m 之前在使用 iOS 14.0 时遇到了以下问题 - 通过后台位置权限我可以:
\n使用 iOS14 重新测试,没有精确的位置,我的应用程序不再因应用程序切换器终止而被唤醒。
\n重新启用精确位置权限,一切都像以前一样。
\n在没有精确位置权限的情况下,我需要做什么才能让后台应用程序唤醒 iBeacon 区域?
\n或者
\n如何检测缺少精确位置权限并通知用户应用程序将无法按预期运行?
\n\ncllocationmanager ibeacon region-monitoring background-task ios14
我只是熟悉了CLLocationManager,发现了几个包含以下init方法的示例类定义:
- (id) init {
self = [super init];
if (self != nil) {
self.locationManager = [[[CLLocationManager alloc] init] autorelease];
self.locationManager.delegate = self;
}
return self;
}
- (void)dealloc {
[self.locationManager release];
[super dealloc];
}
Run Code Online (Sandbox Code Playgroud)
我不明白为什么iVar会被自动释放.这是否意味着它在init方法结束时被释放?
我也很困惑地看到相同的示例代码在dealloc方法中有iVar版本.
有什么想法吗?"
locationServicesEnabled已从属性更改为方法.
不推荐使用:
CLLocationManager *manager = [[CLLocationManager alloc] init];
if (manager.locationServicesEnabled == NO) {
// ...
}
Run Code Online (Sandbox Code Playgroud)
现在我应该使用:
if (![CLLocationManager locationServicesEnabled]) {
// ...
}
Run Code Online (Sandbox Code Playgroud)
我想支持iOS 3和iOS 4设备.如何在iOS 3设备上查看此信息并删除已弃用的警告?
该CLLocationManager提示警报
"应用名称"您想使用您的位置吗?
它提供了两个按钮,OK和Do not allow.如何知道用户选择了哪些按钮?
我一直试图用MKMapview移动我的iOS7应用程序来支持iOS8.但是,我无法获得用户共享其位置以正常工作的新请求.我在故事板上创建我的MKMapView,并且代理设置并在iOS7上完美运行.以下是我为支持iOS8位置共享而添加的内容:
myMapView.h
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
@interface myMapView : UIViewController <MKMapViewDelegate, CLLocationManagerDelegate>
@property (strong, nonatomic) IBOutlet MKMapView *mapView;
@property (strong, nonatomic) CLLocationManager *locationManager;
Run Code Online (Sandbox Code Playgroud)
myMapView.m
//Code omitted
#define IS_OS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
//Code omitted
- (void)viewDidLoad {
[super viewDidLoad];
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
if(IS_OS_8_OR_LATER) {
//[self.locationManager requestWhenInUseAuthorization];
[self.locationManager requestAlwaysAuthorization];
[self.locationManager startUpdatingLocation];
}
[self.mapView setShowsUserLocation:YES];
[self.mapView setUserTrackingMode:MKUserTrackingModeFollow animated:YES];
}
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
MKCoordinateRegion region = { { 0.0, 0.0 }, { …Run Code Online (Sandbox Code Playgroud) ios ×5
objective-c ×4
iphone ×3
swift ×3
xcode ×2
avfoundation ×1
cocoa-touch ×1
healthkit ×1
ibeacon ×1
ios14 ×1
ios8 ×1
mkmapview ×1
permissions ×1
watchkit ×1