Hallo, ich erstell gerade einen Kompass. Habe den folgenden Code in einer anderen App schon einmal benutzt, da hat er fehlerfrei funktioniert. Nun kommt immer die Meldung: Implicit conversion shortens 64-bit value into a 32-bit value. In der Zeile: CGFloat heading = -1.0f * M_PI * newHeading.magneticHeading / 180.0f; tritt der Fehler immer auf.
Alles anzeigen
Danke für Eure Hilfe.
Quellcode
- #import <UIKit/UIKit.h>
- #import <CoreLocation/CoreLocation.h>
- #import <QuartzCore/QuartzCore.h>
- @interface CompassViewController : UIViewController <CLLocationManagerDelegate>
- {
- IBOutlet UIImageView *arrow;
- CLLocationManager *locManager;
- }
- @property (retain) CLLocationManager *locManager;
- @end
- @implementation CompassViewController
- @synthesize locManager;
- - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
- {
- NSLog(@"Location manager error: %@", [error description]);
- }
- - (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
- {
- CGFloat heading = -1.0f * M_PI * newHeading.magneticHeading / 180.0f;
- arrow.transform = CGAffineTransformMakeRotation(heading);
- }
- - (BOOL)locationManagerShouldDisplayHeadingCalibration:(CLLocationManager *)manager
- {
- return YES;
- }
- - (void) viewDidLoad
- {
- self.locManager = [[[CLLocationManager alloc] init] autorelease];
- self.locManager.delegate = self;
- if (self.locManager.headingAvailable)
- [self.locManager startUpdatingHeading];
- else
- arrow.alpha = 0.0f;
- }
- @end
- int main(int argc, char *argv[])
- {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- int retVal = UIApplicationMain(argc, argv, nil, nil);
- [pool release];
- return retVal;
- }
Danke für Eure Hilfe.