PDA

View Full Version : reverseGeocodeLocation fails if I the navigation bar is not translucent



jimt2000
10.03.2016, 23:14
iOS 9

Here's an interesting problem that has eaten up a good chunk of time...

If I have a translucent navigation bar, the call to
<PRE> SKReverseGeocoderService.sharedInstance().reverseG eocodeLocation</PRE>
fails to work. It just returns parent results of
<PRE> US and UT</PRE>
If the navigation bar is not translucent, the call returns parent results of
<PRE> South Jordan, Utah, United States of America, US, UT,</PRE>

It took some time to narrow down the code that reproduces this problem. I finally narrowed it down to this:


override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)

let region = SKCoordinateRegion(center: CLLocationCoordinate2DMake(40.702471, -111.903662), zoomLevel: 9)
mapView.visibleRegion = region

let reverseGeoBlock = {
let centerCoord = self.mapView.coordinateForPoint(self.mapView.cente r)
let searchObject: SKSearchResult = SKReverseGeocoderService.sharedInstance().reverseG eocodeLocation(centerCoord)

if let resultParents = searchObject.parentSearchResults as? [SKSearchResultParent] {
let truth = self.navigationController?.navigationBar.transluce nt == true ? "true" : "false"
print("Navigation translucent = \(truth). ", terminator: " ")
for parent in resultParents {
print("\(parent.name)", terminator: ", ")
}
print("")
}
}

reverseGeoBlock()

self.navigationController?.navigationBar.transluce nt = false
reverseGeoBlock() // bad results

self.navigationController?.navigationBar.transluce nt = true
reverseGeoBlock() // good results

self.navigationController?.navigationBar.transluce nt = false
reverseGeoBlock() // bad results
}

If the storyboard has the navigation bar translucent, the above code produces:
<PRE>
Navigation translucent = true. South Jordan, Utah, United States of America, US, UT,
Navigation translucent = false. US, UT,
Navigation translucent = true. South Jordan, Utah, United States of America, US, UT,
Navigation translucent = false. US, UT,
</PRE>
If the storyboard has the navigation bar translucent unchecked, the above code produces:
<PRE>
Navigation translucent = false. US, UT,
Navigation translucent = false. US, UT,
Navigation translucent = true. South Jordan, Utah, United States of America, US, UT,
Navigation translucent = false. US, UT,
</PRE>

Utah (USUT) is the only map that has been downloaded for offline use.

I hope the code above has enough info to reproduce this problem.

I would love to hear if this is a known issue and will be fixed in the upcoming update.

Thanks!
Jim

Adela_Silvia
16.03.2016, 11:59
Hi Jim,

We'll try to reproduce the problem in our demo app. As soon as we'll have an answer we'll let you know.

jimt2000
17.03.2016, 01:41
Thanks for looking into this.