【问题标题】:I want to be signaled when app found user location.我想在应用找到用户位置时收到信号。
【发布时间】:2011-11-02 13:44:08
【问题描述】:

我使用 MKMapView。

mapView.showsUserLocation = YES;

我希望在应用找到用户位置时收到信号。

【问题讨论】:

    标签: ios gps mkmapview


    【解决方案1】:

    您可以在 mapview 委托的 mapView:didUpdateUserLocation: 方法中处理该事件 - 每次更新用户位置时都会调用它

    【讨论】:

      【解决方案2】:

      简单。

      实现MKMapViewDelegate方法-mapView:didUpdateUserLocation:

      【讨论】:

        【解决方案3】:

        为此,您必须实现委托方法:

        - (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
        

        并将您的班级设置为您的 mapView 代表:

        self.mapView.delegate = self;
        

        如果您愿意,也可以在 IB 中这样做。

        您的课程必须引用 MKMapViewDelegate 协议:

        @interface YourClass : InheritanceObject <MKMapViewDelegate> {
             MKMapView* mapView;
        }
        
        @property(nonatomic, retain) IBOutlet MKMapView* mapView; // IBOutlet if you create the mapView into IB
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2012-01-10
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多