【问题标题】:iPhone sdk location change notificationiPhone sdk 位置变更通知
【发布时间】:2010-11-23 12:34:33
【问题描述】:

我打算在 iPhone 上进行 GPS 定位。能否告诉我有关 GPS 的信息(代表、方法等)。

【问题讨论】:

    标签: iphone


    【解决方案1】:

    查找CLLocationManagerCLLocationManagerDelegate 的文档。如果您仍有具体问题,请回来询问。

    【讨论】:

      【解决方案2】:

      声明一个 CLLocation 的 Location Manager

      CLLocationManager *locManager;
      

      在你的函数中

      self.locManager = [[CLLocationManager alloc] init]; 
      locManager.delegate = self; 
      locManager.desiredAccuracy = kCLLocationAccuracyBest;
      [locManager startUpdatingLocation];   // This Method will call the didUpdateToLocation Delegate
      [locManager stopUpdatingLocation];   //This Methods stops the GPS from updating
      

      位置经理代表

      - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
      {
       //Do actions when the GPS is Updating
      }
      - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
      {
          NSLog(@"Error in GPS: %@",error);  
      }
      

      不要忘记在 .h 文件中包含 CLLocationManagerDelegate 并将 CoreLocation 框架添加到您的项目中

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多