I'm trying to get heading information using ios 4.3 on an iphone 4. I have my dele开发者_JAVA百科gate set correctly but the following delegate method is not being called. Any ideas on what I'm doing wrong?
(void)locationManager:(CLLocationManager *)manager didUpdateHeading: (CLHeading )newHeading)newHeading {
[manager setDelegate:self];
NSLog(@" I'm updating the location information now");
[manager startUpdatingHeading];
NSLog(@" heading info %@",newHeading); }
It looks like you're only telling the Location Manager that you want it to issue updates from within the function it calls when it issues updates, so there's a bit of a chicken-and-egg problem here. Move the calls to -setDelegate:
and -startUpdatingHeading
to someplace where they're sure to get called, like -viewWillAppear
or init
. Make sure that the code is actually being executed.
精彩评论