【发布时间】:2012-02-13 17:15:25
【问题描述】:
是否可以在我自己的应用程序中使用 iOS 自带的指南针?还是我需要自己绘制指南针并为其制作动画?
【问题讨论】:
标签: objective-c ios native compass-geolocation
是否可以在我自己的应用程序中使用 iOS 自带的指南针?还是我需要自己绘制指南针并为其制作动画?
【问题讨论】:
标签: objective-c ios native compass-geolocation
没有原生指南针UIView。为了使用磁力计,您必须使用 CoreLocation 和以下委托方法:
- (void) locationManager:(CLLocationManager *)manager
didUpdateHeading:(CLHeading *)newHeading
将 UIView 旋转到北(bearingView 是 UIImageView):
float heading = newHeading.magneticHeading; //in degrees
float headingDegrees = (heading*M_PI/180); //assuming needle points to top of iphone. convert to radians
self.bearingView.transform = CGAffineTransformMakeRotation(headingDegrees);
【讨论】: