我正在为iOS 7开发一个应用程序,我需要找到用户的位置,然后检查其他用户在同一位置的位置。我需要它更新,一旦用户打开应用程序,以及更新每隔一段时间,并将显示在同一位置的用户。我看过可用的例子,但是使用Parse似乎还不够。有人能帮我做这件事吗?如果有人知道一些类似我想做的事情的例子,我会非常感激的。提前感谢!
发布于 2014-04-07 08:32:09
你需要解决你的问题,解决各种问题-
发布于 2015-08-19 21:26:55
这可能会帮助您获得当前位置,然后保存到解析,这只是查询解析以将数据解压缩的问题。
func locationManager(manager: CLLocationManager!, didUpdateLocations
locations: [AnyObject]!) {
var userLocation : CLLocation = locations[0] as! CLLocation
var latitude = userLocation.coordinate.latitude
var longitude = userLocation.coordinate.longitude
var latDelta : CLLocationDegrees = 0.01
var lonDelta : CLLocationDegrees = 0.01
var span : MKCoordinateSpan = MKCoordinateSpanMake(latDelta,
lonDelta)
var location : CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude)
var region : MKCoordinateRegion = MKCoordinateRegionMake(location, span)
self.mapView.setRegion(region, animated: true)
let testObject = PFObject(className: "User")
let currentPoints = PFGeoPoint(latitude: latitude, longitude: longitude)
testObject.setValue(currentPoints, forKey: "currentLocation")
testObject.saveInBackgroundWithBlock { (success: Bool, error: NSError?) -> Void in
if (success) {
dispatch_async(dispatch_get_main_queue()) {
println("added to parse")
}
} else {
println(error)
}
}
}https://stackoverflow.com/questions/22907018
复制相似问题