Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iphone中未显示指南针_Iphone_Ipad - Fatal编程技术网

iphone中未显示指南针

iphone中未显示指南针,iphone,ipad,Iphone,Ipad,我已经创建了一个应用程序,我想在其中显示指南针。但我的应用程序显示的是空白页。我还添加了CoreLocation框架。请帮助我显示指南针 .h文件代码: viewDidLoad方法代码: NSLog(@"New magnetic heading: %f", newHeading.magneticHeading); NSLog(@"New true heading: %f", newHeading.trueHeading); [super viewDidLoad]; // Do any addi

我已经创建了一个应用程序,我想在其中显示指南针。但我的应用程序显示的是空白页。我还添加了CoreLocation框架。请帮助我显示指南针

.h文件代码: viewDidLoad方法代码:

NSLog(@"New magnetic heading: %f", newHeading.magneticHeading);
NSLog(@"New true heading: %f", newHeading.trueHeading);
[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];

您需要为指南针的指针提供变换

应该是这样的

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor clearColor];

    locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self; 
    locationManager.desiredAccuracy = kCLLocationAccuracyBest; 
    locationManager.distanceFilter = kCLDistanceFilterNone; 
    [locationManager startUpdatingLocation];
    [locationManager startUpdatingHeading];

    CLLocation *location = [locationManager location];
    CLLocationCoordinate2D user = [location coordinate];


}

-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
    CLLocationCoordinate2D here =  newLocation.coordinate;


}

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading {

    double trueheading = newHeading.magneticHeading;
    double northangle = (trueheading*M_PI/180);
    redPin.transform = CGAffineTransformMakeRotation(northangle); 
}

这里的redPin是我的指针视图,顺便说一下,别忘了导入CoreLocation框架

它是否给出任何错误或警告?redPin是imageview,您正在将它与imageview对象绑定…我说得对吗???谢谢..我的手机现在显示compass@斯雷·查兰
- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor clearColor];

    locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self; 
    locationManager.desiredAccuracy = kCLLocationAccuracyBest; 
    locationManager.distanceFilter = kCLDistanceFilterNone; 
    [locationManager startUpdatingLocation];
    [locationManager startUpdatingHeading];

    CLLocation *location = [locationManager location];
    CLLocationCoordinate2D user = [location coordinate];


}

-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
    CLLocationCoordinate2D here =  newLocation.coordinate;


}

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading {

    double trueheading = newHeading.magneticHeading;
    double northangle = (trueheading*M_PI/180);
    redPin.transform = CGAffineTransformMakeRotation(northangle); 
}