如何在mkmapview中停止滚动?

问题描述 投票:0回答:4

我在我的应用程序中使用

MKMapView
并使用
mapView.scrollEnabled=NO;
但它不起作用。这是我的代码:

mapView=[[MKMapView alloc] initWithFrame:CGRectMake(20, 100, 282, 209)];
mapView.delegate=self;
mapView.scrollEnabled=YES;
[self.view addSubview:mapView];

我的代码有问题吗?

ios swift objective-c iphone mkmapview
4个回答
15
投票

您在代码中使用了

YES
而不是
NO
。请使用如下
NO

mapView.scrollEnabled = NO;

斯威夫特

mapView.scrollEnabled = false

3
投票

尝试设置

mapView.scrollEnabled=NO;

或设置

mapView.userInteractionEnabled = NO;

但它不允许您放大或缩小以及其他操作。 单击此处了解更多信息。


2
投票

尝试将

userInteractionEnabled
MKMapView
属性设置为
NO

mapView.userInteractionEnabled = NO;

1
投票

您检查过本教程吗:

向 MKMapView 添加边界

或者这个问题:

防止在 MKMapView 中滚动,以及缩放时

© www.soinside.com 2019 - 2024. All rights reserved.