2015-08-21 26 views
5

मैं अपडेट हेडिंग के लिए कंपास का उपयोग करना चाहता हूं। लेकिन मेरे didUpdateHeading नहीं बुलाया। मैं आईओएस में नया हूँ। कृपया किसी भी मदद की मदद की जा सकती है।didUpdateHeading को कॉल नहीं किया गया

@interface ViewController : UIViewController<CLLocationManagerDelegate> 
@property (nonatomic, retain) CLLocationManager  *locationManager; 
locationManager=[[CLLocationManager alloc] init]; 
    locationManager.desiredAccuracy = kCLLocationAccuracyBest; 
    locationManager.delegate=self; 
    //Start the compass updates. 

    [locationManager startUpdatingHeading]; 

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading 
{ 
    NSLog(@"New magnetic heading: %f", newHeading.magneticHeading); 
    NSLog(@"New true heading: %f", newHeading.trueHeading); 
} 
+0

उपयोग करने के लिए आप किसी भी समाधान मिला की ज़रूरत है? –

+0

मुझे एक ही समस्या है। –

उत्तर

0

शायद तुम ज flie <CLLocationManagerDelegate>

+0

यह पहले से ही @interface में जोड़ा गया है, इससे कोई फ़र्क नहीं पड़ता कि आपने इसे – Simon

2

कोड आपके द्वारा दी गई में प्रतिनिधि भूल गया (यह मानते हुए जब यहां चिपकाने आप कुछ भी नहीं बदला है) पहले भाग को चलाने के लिए एक समारोह या ब्लॉक का एक कोड याद आ रही है , मैं तुम्हें डाल सलाह है कि आपके viewController init में है, इसलिए जैसे:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {   
     locationManager=[[CLLocationManager alloc] init]; 
     locationManager.desiredAccuracy = kCLLocationAccuracyBest; 
     locationManager.delegate=self; 
     //Start the compass updates. 

     [locationManager startUpdatingHeading]; 
    } 
    return self; 
} 
+0

में किस फ़ाइल में रखा है, यह काम नहीं कर रहा है .... –

+0

ठीक है, तो वास्तव में क्या हो रहा है? – Simon

+0

didUpdateToLocation विधि कॉल लेकिन didUpdateHeading कभी भी कॉल नहीं –

0

आप स्थान का उपयोग कर के लिए प्राधिकरण के लिए पूछ रहे हैं? आप

[locationManager requestWhenInUseAuthorization]; 

या

[locationManager requestAlwaysAuthorization]; 
+0

हां मेरा didUpdateToLocation प्रतिनिधि काम करते हैं –

संबंधित मुद्दे