Is the Current Location/Compass heading button available in the iOS sdk?

后端 未结 2 1369
名媛妹妹
名媛妹妹 2020-12-08 12:03

I am working on a sample map kit app for iOS. I have everything working and a toolbar button to toggle the MKUserTrackingMode. This may seem like a silly question but I have

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-08 12:28

    You need to create a MKUserTrackingBarButtonItem and pass it the MKMapview in the constructor, then add that button item to the navigation menu (or where ever it is your button should be).

    - (void)viewDidLoad
    {
        [super viewDidLoad];    
        MKUserTrackingBarButtonItem *buttonItem = [[MKUserTrackingBarButtonItem alloc] initWithMapView:self.map];
        self.navigationItem.rightBarButtonItem = buttonItem;
    }
    

提交回复
热议问题