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

与世无争的帅哥 提交于 2019-11-27 01:08:54

问题


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 searched all the options in the IB and looked in the documentation, and I can't find any button options like the one for the current location/compass heading used in the iOS Maps app. Is that particular button available to developers?


回答1:


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;
}



回答2:


Maybe I am misunderstanding your question but it sounds like you want to be setting the userTrackingMode property of your MKMapView to theMKUserTrackingMode.MKUserTrackingModeFollowWithHeading.



来源:https://stackoverflow.com/questions/9876157/is-the-current-location-compass-heading-button-available-in-the-ios-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!