![](/img/trans.png)
[英]SwiftUI - Show predefined location as a user location on map
我正在構建一個很大程度上依賴於用戶位置的應用程序。 當應用程序啟動時,用戶會看到一系列視圖(入職),在最后一個視圖中有以下選項: A)單擊以獲取您的位置: 在這種情況下,我們按照標准程序使用plist和LocationManager獲取用戶的位置並將其顯示在 map 上。 B)預定義位置: 在這 ...
[英]SwiftUI - Show predefined location as a user location on map
我正在構建一個很大程度上依賴於用戶位置的應用程序。 當應用程序啟動時,用戶會看到一系列視圖(入職),在最后一個視圖中有以下選項: A)單擊以獲取您的位置: 在這種情況下,我們按照標准程序使用plist和LocationManager獲取用戶的位置並將其顯示在 map 上。 B)預定義位置: 在這 ...
[英]Why is my CLLocationManager sometimes updating location twice after startUpdatingLocation is called
按下按鈕后,我有一個 CLLocationManager 請求位置服務授權,如果用戶接受,locationManager 將調用 startUpdatingLocation()。 一旦有更新的位置(立即),我希望 ClLocationManagerDelegate 調用 didUpdateLocat ...
[英]Objective C - How to call UI-process from non-UI class
我正在嘗試在 iOS 中獲取用戶 position。我猜這個問題可能與dispatch_async有關。 我在編譯期間沒有收到錯誤,但只調用了init function 並且 locationManager 從不提供更新。 ...
[英]Swift warning making UI unresponsive
我正在使用 swift 版本 5.7.1 和 Xcode 14.1。 我正在創建具有用戶位置的 Map 應用程序,它工作正常。但問題是,它發出警告。如果在主線程上調用此方法,可能會導致 UI 無響應。 相反,請考慮等待-locationManagerDidChangeAuthorization:回調 ...
[英]"Delegate must respond to locationManager:didUpdateLocations:" error thrown when app does handle it
現在我只是想在屏幕上打印位置,稍后會對其進行擴展,但我得到以下控制台 output(該應用程序也崩潰了 - 它正在物理設備上構建和運行): 這是我正在使用的代碼: 以及視圖的代碼(在不同的 Swift 文件中): 我嘗試重新啟動項目並在物理設備和模擬器上運行構建。 當按下 LocationButto ...
[英]Catch every moment when user change his location
我正在使用谷歌 Map SDK。 我想捕捉用戶更改位置的每一刻,可能來自 CLLocationManagerDelegate。 誰能說哪種方法可以執行以前的工作? 我嘗試使用func locationManager( _ manager: CLLocationManager, didUpdateLo ...
[英]Current Location is Nil In SwiftUI
我在我的 SwiftUI 應用程序中獲取用戶的當前位置。 為了獲得latitude 和 longitude ,我正在使用以下代碼onAppear()我的視圖: 這是打印: 緯度:無 經度:無 我不明白為什么它沒有得到當前位置。 我的info.plist是: 有誰知道是什么問題? ...
[英]How to show in which side user turn prone, if I show user location using MKMapView
我想顯示用戶將手機轉到哪一側,例如在 MapView 上,並且無法理解如何做到這一點,我嘗試使用這些選項,但它們無法幫助我: ...
[英]Automatically include user’s current location in a SMS (Swift)
我正在嘗試構建一個簡單的應用程序,該應用程序具有允許用戶發送自動包含其位置的短信的功能。 我找到了一些代碼,但是它們要么是舊的,要么是使用 Objective-c。 我已經涵蓋了消息的發送,但是我不知道如何自動將用戶的當前位置放在消息正文中。 到目前為止,這是我的代碼: ...
[英]In what scenarios would CLLocationManager return a current location array with more than one entry?
背景 根據委托方法locationManager(manager:locations:)的文檔參數:位置[CLLocation] 包含位置數據的 CLLocation 對象數組。 此數組始終包含至少一個代表當前位置的 object。 如果更新被推遲,或者如果在交付之前到達了多個位置,則數組可能包含 ...
[英]Swift, ClLocationManager slow to fire didEnterRegion
我正在嘗試在項目中使用 clLocationManager 來執行指示。 一切正常,但 didEnterrRegion function 啟動速度非常慢。 測試時,我進入了該區域,但在退出該區域后僅 2-3 分鍾就收到了回調。 有沒有人對如何改進這個有任何建議? 這是位置管理器: 這是我正在跟蹤的 ...
[英]locationManager(_:didUpdateLocations:) last entry is sometimes extremely outdated
根據蘋果自己的關於 CLLocationManager 的文檔 但是,在開發過程中,我有時會注意到locations.last有時會過時幾分鍾到幾小時。 有沒有人有任何想法可能導致這個問題? ...
[英]locationManager.startUpdatingLocation gets executed too late
我正在嘗試使用閉包獲取用戶的當前位置,但它返回一個 nil 值,因為 locationManager.startUpdatingLocation() 在閉包返回 (nil) 值后設置該值。 在使用閉包返回值之前,我不知道如何等待值被設置。 這是我的位置層: ...
[英]Google Maps iOS SDK to user's current location on launch Swift SwiftUI
我試圖模仿谷歌地圖的一些功能,在啟動應用程序時,如果已授予所需的權限,相機就會移動到用戶的當前位置。 我已經使用自定義當前位置按鈕實現了這一點,該按鈕可以很好地將相機帶到用戶當前位置,但在啟動時無法模仿。 map 在位置管理器之后初始化,但是調用 didUpdateLocations 時會有延遲 ...
[英]How to detect when a Beacon is no longer detected by an iOS device?
使用LocationManager.startRangingBeacons方法測距信標時遇到問題。 在為 Beacon 進行測距時,Apple 文檔明確指出,在檢測到 Beacon 時應調用locationManager(_:didRange:satisfying:) ,並且在未檢測到 Beaco ...
[英]Does reverseGeocodeLocation(_ location: CLLocation) method works in offline mode?
我從方法reverseGeocodeLocation(_ location: CLLocation)獲取位置名稱。 我的要求是在離線模式下將 Lat-Long 值存儲在 DB 中,我還想存儲從上述方法獲得的這個位置名稱字符串。 這是我已經實現的: 我絕對可以在離線模式下獲得lat-long; 我的 ...
[英]How to update my location Custom Marker with googleMaps in Swift
我目前正在嘗試創建一種方法來使用自定義圖標更改 googlemaps 的藍點,但目前我遇到標記打印但不清除其最后位置的問題,這是我現在正在使用的代碼“CLLocationManagerDelegate”和“GMSMap” ...
[英]Execute DidRangeBeacons all the time in iOS 15 when user is in the range of beacon
[預期行為:專為 iOS 15。iOS 14 或更低版本工作正常] 我有一個 Xamarin.Forms iOS 應用程序,我在其中監視和測距 BLE 信標。 目標是處於前景、背景或終止狀態,當我進入一個區域時, EnteredRegion() 方法應該調用並且 DidRangeBeacons( ...
[英]CLLocationManager authorization callbacks (when no auth-change)
我的應用程序需要始終授權。 Apple 聲明,如果應用程序已經擁有“WhenInUse”授權,它可能只要求一次“Always”。 因此彈出以下工作流程: 詢問“WhenInUse” 要求“一直” 這里的問題: (在 1 上):如果用戶選擇“允許一次”,我會在內部得到“When ...
[英]How can I initialize a State Var in Swift UI without getting the error “Cannot use instance member 'XXX' within property initializer;”
我希望將用戶位置放在 MapView 上,並在用戶移動時更新位置。 我使用@observedObject Var 作為處理位置管理器內容的類,使用@state Var 作為 MKCoordinateRegion() 類。 但是,我遇到了一個問題,如果我在聲明和定義 @state var 之前放置了 ...