Rotate MapView using Compass orientation

后端 未结 5 1666
故里飘歌
故里飘歌 2020-12-16 04:57

Is it possible to have an embedded MKMapView rotate to always face the direction the iPhone is facing? Basically I want to mimic the Map app rotation feature o

5条回答
  •  暖寄归人
    2020-12-16 05:50

    if you use a navigationVontroller try this:

    //For Left button
     MKUserTrackingBarButtonItem *buttonItem = [[MKUserTrackingBarButtonItem 
                                                     alloc]initWithMapView:_mapView];
    
     self.navigationItem.leftBarButtonItem = buttonItem;
    
    
    // For Right Button
         MKUserTrackingBarButtonItem *buttonItem = [[MKUserTrackingBarButtonItem 
                                                         alloc]initWithMapView:_mapView];
    
         self.navigationItem.rightBarButtonItem = buttonItem;
    

提交回复
热议问题