简体   繁体   English

iOS sdk中是否提供当前位置/指南针标题按钮?

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

I am working on a sample map kit app for iOS. 我正在研究适用于iOS的示例地图套件应用程序。 I have everything working and a toolbar button to toggle the MKUserTrackingMode. 我有一切工作和一个工具栏按钮来切换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. 这可能看起来像一个愚蠢的问题,但我已经搜索了IB中的所有选项并查看了文档,我找不到任何按钮选项,例如iOS Maps应用程序中使用的当前位置/指南针标题。 Is that particular button available to developers? 开发人员可以使用该特定按钮吗?

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). 您需要创建一个MKUserTrackingBarButtonItem并将其传递给构造函数中的MKMapview,然后将该按钮项添加到导航菜单(或者按钮应该在哪里)。

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

也许我误解了你的问题,但听起来你想要将MKMapViewuserTrackingMode属性设置为MKUserTrackingMode.MKUserTrackingModeFollowWithHeading

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM