Thanks Rolf.

Would I have found that if I searched a bit more (it was 10pm on a Sunday
night when I wrote the email)?

If not, I'll throw a blog post up about it.

Thanks!

Nic

--
Nic Wise
t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
b. http://www.fastchicken.co.nz/

mobileAgent (for FreeAgent): get your accounts in your pocket.
http://goo.gl/IuBU
Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
http://www.fastchicken.co.nz/apps

On 17 Sep 2012, at 10:16, Rolf Bjarne Kvinge <[email protected]> wrote:

Hi,

iOS 6 deprecated this selector and calls a new one. That, along with how
events works (by implementing an internal delegate type), is what's causing
the update event not to fire. Calling this method causes the location
manager to obtain an initial location fix (which may take several seconds)
and notify your delegate by calling its locationManager:didUpdateLocations:
method. (In iOS 5 and earlier, the location manager calls the
locationManager:didUpdateToLocation:fromLocation: method instead.)

Here's a patch (from one of our sample) that shows how to deal with this
(using events).
+ if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0)) {
+     iPhoneLocationManager.LocationsUpdated += (object sender,
CLLocationsUpdatedEventArgs e) => {
+         UpdateLocation (e.Locations [e.Locations.Length - 1]);
+     };
+ } else {
+     // this won't be called on iOS 6 (deprecated)
+     iPhoneLocationManager.UpdatedLocation += (object sender,
CLLocationUpdatedEventArgs e) => {
+         UpdateLocation (e.NewLocation);
+     };
+ }

[this is from one of our internal bugs, which Sebastien tracked down to
this issue]

Rolf

On Sun, Sep 16, 2012 at 11:03 PM, Nic Wise <[email protected]> wrote:

> Hi there
>
> I have some location code which has been working for ages. I've just
> been moving things to iOS6 (esp the new screensize) and I've moved
> from 5.4.1 to 5.99.3 (or .4 - whatever is current on the alpha
> channel). The location code doesn't appear to be working. It's VERY
> simple:
>
> CLLocationManager locationManager = null;
>
> public void GetForCurrentLocation (Action<List<Marker>, int>
> OnRegionUpdate)
> {
>
>
>     if (CLLocationManager.LocationServicesEnabled)
>     {
>         if (locationManager == null)
>         {
>             locationManager = new CLLocationManager ();
>             locationManager.DesiredAccuracy =
> CLLocation.AccuracyNearestTenMeters;
>             locationManager.UpdatedLocation += delegate(object sender,
> CLLocationUpdatedEventArgs e) {
>
>                 //do something with it. This never gets called in
> 5.99.x, but does in 5.4.1
>
>             };
>
>
>
>             locationManager.Failed += delegate(object sender,
> NSErrorEventArgs e) {
>                 //handle the errors
>             };
>
>         }
>
>         locationManager.StartUpdatingLocation ();
>     } else {
>         Util.Log ("Location services is not available");
>     }
> }
>
> This is in a class, and the class it kept around. The UpdatedLocation
> method is never called in 5.99.x, but if I switch to 5.4 and clean and
> rebuild, it all works again (this is all with iOS6 SDK and iOS6 4"
> retina display simulator, or on my phone)
>
> Is this a known regression? Happy to raise a bug if it's not a known thing.
>
> Thanks
>
> Nic
>
> --
> Nic Wise
> t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
> b. http://www.fastchicken.co.nz/
>
> mobileAgent (for FreeAgent): get your accounts in your pocket.
> http://goo.gl/IuBU
> Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
> Earnest: Self-employed? Track your business expenses and income.
> http://earnestapp.com
> Nearest Bus: find when the next bus is coming to your stop.
> http://goo.gl/Vcz1p
> London Bike App: Find the nearest Boris Bike, and get riding!
> http://goo.gl/Icp2
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch
>
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to