iOS SDK中是否提供“当前位置/指南针"标题按钮? [英] Is the Current Location/Compass heading button available in the iOS sdk?
问题描述
我正在开发适用于iOS的示例地图套件应用.我一切正常,并使用工具栏按钮切换MKUserTrackingMode.这似乎是一个愚蠢的问题,但是我已经搜索了IB中的所有选项,并查看了文档,但找不到与iOS Maps应用程序中当前位置/指南针标题相同的按钮选项.开发人员可以使用该特定按钮吗?
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?
推荐答案
您需要创建一个MKUserTrackingBarButtonItem并将其传递给构造函数中的MKMapview,然后将该按钮项添加到导航菜单中(或将其作为按钮的位置)是).
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;
}
这篇关于iOS SDK中是否提供“当前位置/指南针"标题按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!