开发者

How can i draw a compass like iphone 3gs in ios4?

开发者 https://www.devze.com 2023-01-10 02:50 出处:网络
开发者_运维问答I\'m trying to make a view like compass in iphone 3gs or iphone4. Do you know somebody how can I start?, I can\'t find too much information about this issue...I only want to draw an arr

开发者_运维问答I'm trying to make a view like compass in iphone 3gs or iphone4. Do you know somebody how can I start?, I can't find too much information about this issue...I only want to draw an arrow always following the north. I'm using ios 4.0

Thanks in advance


Start heading updates with:

if([CLLocationManager headingAvailable]) {
    CLLocationManager *locationManager = [[CLLocationManager alloc] init];

    // myDelegateObject is an instance of a class implementing the CLLocationManagerDelegate protocol
    locationManger.delegate = myDelegateObject;
    [locationManager startUpdatingHeading];
}

Implement the CLLocationManagerDelegate protocol on one of your classes -- in particular, something like:

-(void)locationManager:(CLLocationManager*)manager didUpdateHeading:(CLHeading*)heading {
    // CLLocationDirection is a double typedef
    CLLocationDirection headingInDegrees = heading.magneticHeading;

    // you'll have to implement this in some fashion...
    [myCompassViewController rotateCompassImageToHeading:headingInDegrees];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消