@claude31
I feel like the problem is not knowing where I should insert your code, so here is my entire code, and you determine which line I should put your code at (this is in the viewController btw):
import MapKit
import UIKit
import CoreLocation
import UserNotifications
class ViewController: UIViewController, CLLocationManagerDelegate {
@IBOutlet var mapView: MKMapView!
let manager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
manager.desiredAccuracy = kCLLocationAccuracyBest
manager.delegate = self
manager.requestWhenInUseAuthorization()
manager.startUpdatingLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if let location = locations.first{
manager.stopUpdatingLocation()
render(location)
}
func render(_ location: CLLocation){
let coordinate = CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude)
let span = MKCoordinateSpan (latitudeDelta: 0.1, longitudeDelta: 0.1)
let region = MKCoordinateRegion(center: coordinate, span: span)
mapView.setRegion(region, animated: true)
mapView.showsUserLocation = true
let pin = MKPointAnnotation()
pin.coordinate = coordinate
pin.title = "your home"
pin.subtitle = "Location"
mapView.addAnnotation(pin)
func userDistance(from point: MKPointAnnotation) -> Double? {
guard let userLocation = mapView.userLocation.location else {
return nil // User location unknown!
}
let pointLocation = CLLocation(
latitude: point.coordinate.latitude,
longitude: point.coordinate.longitude
)
//hello
var value = userLocation.distance(from: pointLocation)
return value
}
}
}
@IBAction func Button(_ sender: UIButton) {
UIApplication.shared.open(URL(string: "https://www.gps-coordinates.net")! as URL, options: [:], completionHandler: nil)
}
}
Post
Replies
Boosts
Views
Activity
@Claude31, the button in this project has nothing to do with the label I made displaying the live distance from a pinned spot. And in your code, the label doesn't show anything, so please tell me how to fix this
How do I update ONLY IPHONE screenshot instead of need to update IPAD screenshot as well?
I don't understand the question, could you please be more specific on what your app is trying to do?
I don't really understand what you are saying, but I think if you just close one of the simulators, the problem should be solved.
If that doesn't solve it, please send a screenshot.
Ok, first of all, that's the dumbest idea on the planet. Had your daughter been more responsible and kept the phone in her pocket instead, this wouldn't have happened. Next, you should have probably enabled two-step verification on her iCloud account, so the guy who stole it couldn't have got in.
yeah, autocorrect deleted it
Hi eskimo! I actually fixed the error by using breapoints. Here's how I did it:
First I went to the breakpoint menu and clicked add, then I added an exception break point and other stuff. i easily located the issue after that
this is what I have right now
Excuse me sir. I am struggling and I would really appreciate a reply @Developer Tools Engineer
My app goes off of pre-order in 7 hours, and I have no idea if this is going to work or not.