我正试图在iphone 3gs或iphone4中制作像罗盘一样的视图。你知道有人怎么开始吗?我找不到太多关于这个问题的信息...我只想画一个跟随北方的箭头。 我正在使用ios 4.0
提前致谢
答案 0 :(得分:1)
使用以下命令开始标题更新:
if([CLLocationManager headingAvailable]) {
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
// myDelegateObject is an instance of a class implementing the CLLocationManagerDelegate protocol
locationManger.delegate = myDelegateObject;
[locationManager startUpdatingHeading];
}
在您的某个类上实现CLLocationManagerDelegate协议 - 特别是:
-(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];
}