1. --> in .h File include -->CLLocationManagerDelegate
2. in .m FIle --- >
a. ViewDidLoad LManager=[[CLLocationManager alloc]init];
LManager.desiredAccuracy = kCLLocationAccuracyBest;
LManager.delegate=self;
[LManager startUpdatingHeading];
Degree=0;
b. Delegate Methods - (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
Compass_Not_Dect_Camera.hidden=YES;
double curLocation=newHeading.magneticHeading;
if(PreLocation-curLocation>5 || PreLocation-curLocation<-5)
{
CGAffineTransform rotate = CGAffineTransformMakeRotation( newHeading.magneticHeading/180*3.14 );
[arrow setTransform:rotate];
Degree=newHeading.magneticHeading;
Degree=Degree/90;
PreLocation=newHeading.magneticHeading;
}
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
[LManager stopUpdatingLocation];
[LManager release];
Compass_Not_Dect_lbl.text=@"Compass Not Detected";
}
Loading
No comments:
Post a Comment