我创建了一个应用程序,我想在其中显示指南针。但我的应用程序显示空白页..我还添加了 CoreLocation 框架..请帮我显示指南针。
.h 文件代码:
import "UIKit/UIKit.h"
import "CoreLocation/CoreLocation.h"
@interface Compass_VIew : UIViewController<CLLocationManagerDelegate>
{
IBOutlet UIImageView *arrow;
IBOutlet UIImageView *arrowC;
CLLocationManager *locManager;
}
@property (nonatomic, retain) CLLocationManager *locManager;
@property(readonly, nonatomic) BOOL headingAvailable;
@end
.m 文件代码
didUpdateHeading 方法代码:
NSLog(@"New magnetic heading: %f", newHeading.magneticHeading);
NSLog(@"New true heading: %f", newHeading.trueHeading);
viewDidLoad 方法代码:
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[[self navigationController] setNavigationBarHidden:NO animated:NO];
locManager = [[[CLLocationManager alloc] init] autorelease];
locManager.desiredAccuracy= kCLLocationAccuracyBest;
locManager.delegate = self;
[self.locManager startUpdatingHeading];