gpt4 book ai didi

ios - 如何在MKMapView iOS上以编程方式显示用户位置?

转载 作者:行者123 更新时间:2023-12-01 19:06:25 25 4
gpt4 key购买 nike

我正在尝试制作一个具有MKMapView的应用程序,您可以打开/关闭它是否显示您的位置。我正在使用UIActionSheet来让用户决定打开/关闭showsUserLocation。问题不在于UIActionSheet,而是当我选择YES选项时,似乎无法使MKMapView显示用户位置。
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex方法中的代码:

// Show User Location ActionSheet
if (actionSheet.tag == 1) {

// YES Button
if (buttonIndex == 0) {
MapView.showsUserLocation = YES;

}

// NO Button
if (buttonIndex == 1) {
MapView.showsUserLocation = NO;

}

}

即使我按YES按钮,也没有显示用户的位置。请帮助?!?!

最佳答案

没关系,我找到了一段对我有很大帮助的视频!

http://www.youtube.com/watch?v=KTDXzYzIhVI

YouTube上的本教程帮助我在MKMapView上显示用户的位置。原来,在- (void)viewDidLoad方法中,我需要添加[MapView setDelegate:self];。天哪,这是一个愚蠢的错误! :P

关于ios - 如何在MKMapView iOS上以编程方式显示用户位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19430913/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com