2

I'm using a MKMapView in my application and use mapView.scrollEnabled=NO; but it's not working. Here is my code:

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

Is there something wrong with my code?

HangarRash
  • 7,314
  • 5
  • 5
  • 32
San
  • 247
  • 2
  • 12

3 Answers3

15

You have used YES instead of NO in your code. Please use NO as below.

mapView.scrollEnabled = NO;

Swift

mapView.isScrollEnabled = false
Inder Kumar Rathore
  • 39,458
  • 17
  • 135
  • 184
3

Try to set

mapView.scrollEnabled=NO;

or set

mapView.userInteractionEnabled = NO;

but it does not allow you to zoom in or out and other things. click here for more info.

Community
  • 1
  • 1
Girish
  • 4,692
  • 4
  • 35
  • 55
2

Try to set userInteractionEnabled property of MKMapView to NO.

mapView.userInteractionEnabled = NO;
Hemang
  • 26,840
  • 19
  • 119
  • 186
Andrea Mario Lufino
  • 7,921
  • 12
  • 47
  • 78