Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
257 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...