Disable compass on MKMapViewHow to hide circular compass icon on MKMapview in iOSHow can I disable the UITableView selection?iPhone 3D compassCompass True Heading in iPhone/iPadHow to disable scrolling in UITableView table when the content fits on the screenMKMapView addAnnotation not on the MapViewMKMapView addAnnotations crashHow to disable compass usage in Google Maps for iOS?is there a way of showing MKMapView from an angle (not directly from the top) on a specific zoom level?Disable two finger tap zoom out on MKMapView?How to adjust the compass to the map in osmdroid

How does buying out courses with grant money work?

How to Reset Passwords on Multiple Websites Easily?

Sort a list by elements of another list

Type int? vs type int

What can we do to stop prior company from asking us questions?

How does Loki do this?

Large drywall patch supports

How to be diplomatic in refusing to write code that breaches the privacy of our users

How did Doctor Strange see the winning outcome in Avengers: Infinity War?

Pole-zeros of a real-valued causal FIR system

How does it work when somebody invests in my business?

Why, precisely, is argon used in neutrino experiments?

System.debug(JSON.Serialize(o)) Not longer shows full string

Lay out the Carpet

Class Action - which options I have?

Gears on left are inverse to gears on right?

Inappropriate reference requests from Journal reviewers

Is there a korbon needed for conversion?

Purchasing a ticket for someone else in another country?

How easy is it to start Magic from scratch?

I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?

when is out of tune ok?

How long to clear the 'suck zone' of a turbofan after start is initiated?

How do I extract a value from a time formatted value in excel?



Disable compass on MKMapView


How to hide circular compass icon on MKMapview in iOSHow can I disable the UITableView selection?iPhone 3D compassCompass True Heading in iPhone/iPadHow to disable scrolling in UITableView table when the content fits on the screenMKMapView addAnnotation not on the MapViewMKMapView addAnnotations crashHow to disable compass usage in Google Maps for iOS?is there a way of showing MKMapView from an angle (not directly from the top) on a specific zoom level?Disable two finger tap zoom out on MKMapView?How to adjust the compass to the map in osmdroid













14















I am using a MapView in my app to show some annotations. In iOS 7 a compass appears randomly on the map. I can't reproduce the error because it appears randomly but I want to disable it.
Any ideas how to disable it?



Update: I found out is not appears randomly but on a specific gesture. When you use 2 fingers and slide one right and the other left.










share|improve this question



















  • 2





    That gesture is also known as "rotate"

    – Craig
    Oct 8 '13 at 21:09















14















I am using a MapView in my app to show some annotations. In iOS 7 a compass appears randomly on the map. I can't reproduce the error because it appears randomly but I want to disable it.
Any ideas how to disable it?



Update: I found out is not appears randomly but on a specific gesture. When you use 2 fingers and slide one right and the other left.










share|improve this question



















  • 2





    That gesture is also known as "rotate"

    – Craig
    Oct 8 '13 at 21:09













14












14








14


4






I am using a MapView in my app to show some annotations. In iOS 7 a compass appears randomly on the map. I can't reproduce the error because it appears randomly but I want to disable it.
Any ideas how to disable it?



Update: I found out is not appears randomly but on a specific gesture. When you use 2 fingers and slide one right and the other left.










share|improve this question
















I am using a MapView in my app to show some annotations. In iOS 7 a compass appears randomly on the map. I can't reproduce the error because it appears randomly but I want to disable it.
Any ideas how to disable it?



Update: I found out is not appears randomly but on a specific gesture. When you use 2 fingers and slide one right and the other left.







ios macos mapkit compass-geolocation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '15 at 17:09









Mark Amery

64.4k31257304




64.4k31257304










asked Oct 5 '13 at 9:02









BlackMBlackM

2,18863157




2,18863157







  • 2





    That gesture is also known as "rotate"

    – Craig
    Oct 8 '13 at 21:09












  • 2





    That gesture is also known as "rotate"

    – Craig
    Oct 8 '13 at 21:09







2




2





That gesture is also known as "rotate"

– Craig
Oct 8 '13 at 21:09





That gesture is also known as "rotate"

– Craig
Oct 8 '13 at 21:09












8 Answers
8






active

oldest

votes


















27














You can disable the compass easily on OSX 10.9 / iOS 9 and later with the showsCompass property:



yourMapView.showsCompass = NO;


On iOS 8 or earlier, your choices are:



  1. Suck it up and live with it.



  2. Use a hack, like:



    • position the map to hide the compass offscreen (credit goes to Alex Wien), or


    • walk the view hierarchy of the map to find the view representing the compass and remove it (credit goes to David Topolansky).




  3. If you're not rotating the map programatically and it hasn't already been rotated, disable rotation entirely, using



    mapView.rotateEnabled = NO;


    The compass only shows up when the map is rotated, so by doing this you ensure that the compass is never triggered.



It's not clear to me why Apple waited so long to allow hiding the compass on iOS, and none of the options above are ideal. Pick whichever you think is the least bad in your case.






share|improve this answer
































    7














    I found a solution to your problem, using Mark Amery's idea about traversing the MKMapView instance subviews to find the compass, along with the use of gesture recognition to trigger the removal event.



    To find the compass I printed out the description of the views and found that one of the views was an instance of MKCompassView, this was obviously the compass.



    I have come up with the following code that should work for you. It checks for a rotation gesture, and then removes the view in method triggered by the gesture event.



    I have tested this method and it works well for me:



    - (void)viewDidLoad

    [super viewDidLoad];

    UIRotationGestureRecognizer *rotateGesture = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotate:)];

    [self.mapView addGestureRecognizer:rotateGesture];


    -(void)rotate:(UIRotationGestureRecognizer *)gesture

    if ([gesture state] == UIGestureRecognizerStateBegan





    share|improve this answer


















    • 1





      Would this count as "using a private API," and get flagged during Apple's scan of your binary?

      – Matt H.
      Mar 13 '14 at 23:00











    • Nice - I'm surprised it turns out that this hack is so simple to implement and understand. I don't have access to a Mac nowadays, so I'm not able to test this, but will take your word for it that it works. I've edited a link to your answer into mine.

      – Mark Amery
      Apr 13 '14 at 12:17












    • Doesn't work for me (iOS 8.1.2).. :(

      – Aleksander
      Jan 5 '15 at 23:59











    • The rotate gesture doesn't work for me, but I implemented - (void)viewDidLayoutSubviews method of my view controller and moved the code there, now it works.

      – Andrei Marincas
      May 7 '15 at 13:23



















    4














    Create a wrapper UIView with the frame you want for your map and clipsToBounds set to YES (or equivalently, Clip Subviews set in Interface Builder). Then put your MKMapView inside that wrapper view, with the y co-ordinate of the map's frame set to, for example, -80, and the height of the map set such that its vertical center is aligned with its parent.



    Then the compass will be displayed but you cannot see it, because it is above the top of its parent view - problem solved.






    share|improve this answer
































      1














      Here is solution for Swift 4:



      mapView.compassView.isHidden = true





      share|improve this answer






























        0














        Here swift code:



        let mapRotateGesture = UIRotationGestureRecognizer(target: self, action: "didRotateMap:")
        mapRotateGesture.delegate = self
        self.map.addGestureRecognizer(mapRotateGesture)

        func didRotateMap(gesture: UIGestureRecognizer)
        // Removeing compass
        if (gesture.state == .Began





        share|improve this answer






























          0














          You can hide the compass on MKMapView while rotating the map by adding below line in viewDidLoad method in all iOS:



          [self.mapView setLayoutMargins:UIEdgeInsetsMake(-50, 0, -50, 0)];





          share|improve this answer






























            0














            Completely hides the compass and does not rotate the map



            mapView.allowsRotating = false


            Swift 4, Mapbox-iOS-SDK (4.9.0)






            share|improve this answer






























              -2














              As I understand what you want is to forbid showing user's current location.
              You should use @property(nonatomic) BOOL showsUserLocation.
              Docs on this



              Assume that @property(nonatomic) MKUserTrackingMode userTrackingMode
              can't enable or disable tracking, it's just changes the mode between not following, following and following with rotating.






              share|improve this answer























              • No, I need to show the user location. What I don't need is the compass.

                – BlackM
                Oct 5 '13 at 9:46











              • I found out is not appears randomly but on a specific gesture. When you use 2 fingers and the one slide right and the other left.

                – BlackM
                Oct 5 '13 at 9:55











              • Well, now I understand what you want. The only way docs show to us to disable map's rotating using rotateEnabled. This will prevent rotate Gesture from being enabled.

                – Vladislav Mazur
                Oct 5 '13 at 10:15












              • And if you need to rotate your map, you can add UIRotationGestureRecognizer to map's view add rotate it in way you want using [mapView setTransform:CGAffineTransformMakeRotation(rotation)]; and annotations too.

                – Vladislav Mazur
                Oct 5 '13 at 10:38






              • 1





                @VladislavMazur What is so difficult to understand? He want to disable the compass when he wants, and keep the rotation feature.

                – AlexWien
                Oct 11 '13 at 13:12










              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19195936%2fdisable-compass-on-mkmapview%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              8 Answers
              8






              active

              oldest

              votes








              8 Answers
              8






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              27














              You can disable the compass easily on OSX 10.9 / iOS 9 and later with the showsCompass property:



              yourMapView.showsCompass = NO;


              On iOS 8 or earlier, your choices are:



              1. Suck it up and live with it.



              2. Use a hack, like:



                • position the map to hide the compass offscreen (credit goes to Alex Wien), or


                • walk the view hierarchy of the map to find the view representing the compass and remove it (credit goes to David Topolansky).




              3. If you're not rotating the map programatically and it hasn't already been rotated, disable rotation entirely, using



                mapView.rotateEnabled = NO;


                The compass only shows up when the map is rotated, so by doing this you ensure that the compass is never triggered.



              It's not clear to me why Apple waited so long to allow hiding the compass on iOS, and none of the options above are ideal. Pick whichever you think is the least bad in your case.






              share|improve this answer





























                27














                You can disable the compass easily on OSX 10.9 / iOS 9 and later with the showsCompass property:



                yourMapView.showsCompass = NO;


                On iOS 8 or earlier, your choices are:



                1. Suck it up and live with it.



                2. Use a hack, like:



                  • position the map to hide the compass offscreen (credit goes to Alex Wien), or


                  • walk the view hierarchy of the map to find the view representing the compass and remove it (credit goes to David Topolansky).




                3. If you're not rotating the map programatically and it hasn't already been rotated, disable rotation entirely, using



                  mapView.rotateEnabled = NO;


                  The compass only shows up when the map is rotated, so by doing this you ensure that the compass is never triggered.



                It's not clear to me why Apple waited so long to allow hiding the compass on iOS, and none of the options above are ideal. Pick whichever you think is the least bad in your case.






                share|improve this answer



























                  27












                  27








                  27







                  You can disable the compass easily on OSX 10.9 / iOS 9 and later with the showsCompass property:



                  yourMapView.showsCompass = NO;


                  On iOS 8 or earlier, your choices are:



                  1. Suck it up and live with it.



                  2. Use a hack, like:



                    • position the map to hide the compass offscreen (credit goes to Alex Wien), or


                    • walk the view hierarchy of the map to find the view representing the compass and remove it (credit goes to David Topolansky).




                  3. If you're not rotating the map programatically and it hasn't already been rotated, disable rotation entirely, using



                    mapView.rotateEnabled = NO;


                    The compass only shows up when the map is rotated, so by doing this you ensure that the compass is never triggered.



                  It's not clear to me why Apple waited so long to allow hiding the compass on iOS, and none of the options above are ideal. Pick whichever you think is the least bad in your case.






                  share|improve this answer















                  You can disable the compass easily on OSX 10.9 / iOS 9 and later with the showsCompass property:



                  yourMapView.showsCompass = NO;


                  On iOS 8 or earlier, your choices are:



                  1. Suck it up and live with it.



                  2. Use a hack, like:



                    • position the map to hide the compass offscreen (credit goes to Alex Wien), or


                    • walk the view hierarchy of the map to find the view representing the compass and remove it (credit goes to David Topolansky).




                  3. If you're not rotating the map programatically and it hasn't already been rotated, disable rotation entirely, using



                    mapView.rotateEnabled = NO;


                    The compass only shows up when the map is rotated, so by doing this you ensure that the compass is never triggered.



                  It's not clear to me why Apple waited so long to allow hiding the compass on iOS, and none of the options above are ideal. Pick whichever you think is the least bad in your case.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited May 23 '17 at 12:16









                  Community

                  11




                  11










                  answered Oct 5 '13 at 10:29









                  Mark AmeryMark Amery

                  64.4k31257304




                  64.4k31257304























                      7














                      I found a solution to your problem, using Mark Amery's idea about traversing the MKMapView instance subviews to find the compass, along with the use of gesture recognition to trigger the removal event.



                      To find the compass I printed out the description of the views and found that one of the views was an instance of MKCompassView, this was obviously the compass.



                      I have come up with the following code that should work for you. It checks for a rotation gesture, and then removes the view in method triggered by the gesture event.



                      I have tested this method and it works well for me:



                      - (void)viewDidLoad

                      [super viewDidLoad];

                      UIRotationGestureRecognizer *rotateGesture = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotate:)];

                      [self.mapView addGestureRecognizer:rotateGesture];


                      -(void)rotate:(UIRotationGestureRecognizer *)gesture

                      if ([gesture state] == UIGestureRecognizerStateBegan





                      share|improve this answer


















                      • 1





                        Would this count as "using a private API," and get flagged during Apple's scan of your binary?

                        – Matt H.
                        Mar 13 '14 at 23:00











                      • Nice - I'm surprised it turns out that this hack is so simple to implement and understand. I don't have access to a Mac nowadays, so I'm not able to test this, but will take your word for it that it works. I've edited a link to your answer into mine.

                        – Mark Amery
                        Apr 13 '14 at 12:17












                      • Doesn't work for me (iOS 8.1.2).. :(

                        – Aleksander
                        Jan 5 '15 at 23:59











                      • The rotate gesture doesn't work for me, but I implemented - (void)viewDidLayoutSubviews method of my view controller and moved the code there, now it works.

                        – Andrei Marincas
                        May 7 '15 at 13:23
















                      7














                      I found a solution to your problem, using Mark Amery's idea about traversing the MKMapView instance subviews to find the compass, along with the use of gesture recognition to trigger the removal event.



                      To find the compass I printed out the description of the views and found that one of the views was an instance of MKCompassView, this was obviously the compass.



                      I have come up with the following code that should work for you. It checks for a rotation gesture, and then removes the view in method triggered by the gesture event.



                      I have tested this method and it works well for me:



                      - (void)viewDidLoad

                      [super viewDidLoad];

                      UIRotationGestureRecognizer *rotateGesture = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotate:)];

                      [self.mapView addGestureRecognizer:rotateGesture];


                      -(void)rotate:(UIRotationGestureRecognizer *)gesture

                      if ([gesture state] == UIGestureRecognizerStateBegan





                      share|improve this answer


















                      • 1





                        Would this count as "using a private API," and get flagged during Apple's scan of your binary?

                        – Matt H.
                        Mar 13 '14 at 23:00











                      • Nice - I'm surprised it turns out that this hack is so simple to implement and understand. I don't have access to a Mac nowadays, so I'm not able to test this, but will take your word for it that it works. I've edited a link to your answer into mine.

                        – Mark Amery
                        Apr 13 '14 at 12:17












                      • Doesn't work for me (iOS 8.1.2).. :(

                        – Aleksander
                        Jan 5 '15 at 23:59











                      • The rotate gesture doesn't work for me, but I implemented - (void)viewDidLayoutSubviews method of my view controller and moved the code there, now it works.

                        – Andrei Marincas
                        May 7 '15 at 13:23














                      7












                      7








                      7







                      I found a solution to your problem, using Mark Amery's idea about traversing the MKMapView instance subviews to find the compass, along with the use of gesture recognition to trigger the removal event.



                      To find the compass I printed out the description of the views and found that one of the views was an instance of MKCompassView, this was obviously the compass.



                      I have come up with the following code that should work for you. It checks for a rotation gesture, and then removes the view in method triggered by the gesture event.



                      I have tested this method and it works well for me:



                      - (void)viewDidLoad

                      [super viewDidLoad];

                      UIRotationGestureRecognizer *rotateGesture = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotate:)];

                      [self.mapView addGestureRecognizer:rotateGesture];


                      -(void)rotate:(UIRotationGestureRecognizer *)gesture

                      if ([gesture state] == UIGestureRecognizerStateBegan





                      share|improve this answer













                      I found a solution to your problem, using Mark Amery's idea about traversing the MKMapView instance subviews to find the compass, along with the use of gesture recognition to trigger the removal event.



                      To find the compass I printed out the description of the views and found that one of the views was an instance of MKCompassView, this was obviously the compass.



                      I have come up with the following code that should work for you. It checks for a rotation gesture, and then removes the view in method triggered by the gesture event.



                      I have tested this method and it works well for me:



                      - (void)viewDidLoad

                      [super viewDidLoad];

                      UIRotationGestureRecognizer *rotateGesture = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotate:)];

                      [self.mapView addGestureRecognizer:rotateGesture];


                      -(void)rotate:(UIRotationGestureRecognizer *)gesture

                      if ([gesture state] == UIGestureRecognizerStateBegan






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Feb 28 '14 at 17:11









                      David TopolanskyDavid Topolansky

                      7112




                      7112







                      • 1





                        Would this count as "using a private API," and get flagged during Apple's scan of your binary?

                        – Matt H.
                        Mar 13 '14 at 23:00











                      • Nice - I'm surprised it turns out that this hack is so simple to implement and understand. I don't have access to a Mac nowadays, so I'm not able to test this, but will take your word for it that it works. I've edited a link to your answer into mine.

                        – Mark Amery
                        Apr 13 '14 at 12:17












                      • Doesn't work for me (iOS 8.1.2).. :(

                        – Aleksander
                        Jan 5 '15 at 23:59











                      • The rotate gesture doesn't work for me, but I implemented - (void)viewDidLayoutSubviews method of my view controller and moved the code there, now it works.

                        – Andrei Marincas
                        May 7 '15 at 13:23













                      • 1





                        Would this count as "using a private API," and get flagged during Apple's scan of your binary?

                        – Matt H.
                        Mar 13 '14 at 23:00











                      • Nice - I'm surprised it turns out that this hack is so simple to implement and understand. I don't have access to a Mac nowadays, so I'm not able to test this, but will take your word for it that it works. I've edited a link to your answer into mine.

                        – Mark Amery
                        Apr 13 '14 at 12:17












                      • Doesn't work for me (iOS 8.1.2).. :(

                        – Aleksander
                        Jan 5 '15 at 23:59











                      • The rotate gesture doesn't work for me, but I implemented - (void)viewDidLayoutSubviews method of my view controller and moved the code there, now it works.

                        – Andrei Marincas
                        May 7 '15 at 13:23








                      1




                      1





                      Would this count as "using a private API," and get flagged during Apple's scan of your binary?

                      – Matt H.
                      Mar 13 '14 at 23:00





                      Would this count as "using a private API," and get flagged during Apple's scan of your binary?

                      – Matt H.
                      Mar 13 '14 at 23:00













                      Nice - I'm surprised it turns out that this hack is so simple to implement and understand. I don't have access to a Mac nowadays, so I'm not able to test this, but will take your word for it that it works. I've edited a link to your answer into mine.

                      – Mark Amery
                      Apr 13 '14 at 12:17






                      Nice - I'm surprised it turns out that this hack is so simple to implement and understand. I don't have access to a Mac nowadays, so I'm not able to test this, but will take your word for it that it works. I've edited a link to your answer into mine.

                      – Mark Amery
                      Apr 13 '14 at 12:17














                      Doesn't work for me (iOS 8.1.2).. :(

                      – Aleksander
                      Jan 5 '15 at 23:59





                      Doesn't work for me (iOS 8.1.2).. :(

                      – Aleksander
                      Jan 5 '15 at 23:59













                      The rotate gesture doesn't work for me, but I implemented - (void)viewDidLayoutSubviews method of my view controller and moved the code there, now it works.

                      – Andrei Marincas
                      May 7 '15 at 13:23






                      The rotate gesture doesn't work for me, but I implemented - (void)viewDidLayoutSubviews method of my view controller and moved the code there, now it works.

                      – Andrei Marincas
                      May 7 '15 at 13:23












                      4














                      Create a wrapper UIView with the frame you want for your map and clipsToBounds set to YES (or equivalently, Clip Subviews set in Interface Builder). Then put your MKMapView inside that wrapper view, with the y co-ordinate of the map's frame set to, for example, -80, and the height of the map set such that its vertical center is aligned with its parent.



                      Then the compass will be displayed but you cannot see it, because it is above the top of its parent view - problem solved.






                      share|improve this answer





























                        4














                        Create a wrapper UIView with the frame you want for your map and clipsToBounds set to YES (or equivalently, Clip Subviews set in Interface Builder). Then put your MKMapView inside that wrapper view, with the y co-ordinate of the map's frame set to, for example, -80, and the height of the map set such that its vertical center is aligned with its parent.



                        Then the compass will be displayed but you cannot see it, because it is above the top of its parent view - problem solved.






                        share|improve this answer



























                          4












                          4








                          4







                          Create a wrapper UIView with the frame you want for your map and clipsToBounds set to YES (or equivalently, Clip Subviews set in Interface Builder). Then put your MKMapView inside that wrapper view, with the y co-ordinate of the map's frame set to, for example, -80, and the height of the map set such that its vertical center is aligned with its parent.



                          Then the compass will be displayed but you cannot see it, because it is above the top of its parent view - problem solved.






                          share|improve this answer















                          Create a wrapper UIView with the frame you want for your map and clipsToBounds set to YES (or equivalently, Clip Subviews set in Interface Builder). Then put your MKMapView inside that wrapper view, with the y co-ordinate of the map's frame set to, for example, -80, and the height of the map set such that its vertical center is aligned with its parent.



                          Then the compass will be displayed but you cannot see it, because it is above the top of its parent view - problem solved.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Oct 11 '13 at 14:19









                          Mark Amery

                          64.4k31257304




                          64.4k31257304










                          answered Oct 11 '13 at 13:10









                          AlexWienAlexWien

                          25.2k54172




                          25.2k54172





















                              1














                              Here is solution for Swift 4:



                              mapView.compassView.isHidden = true





                              share|improve this answer



























                                1














                                Here is solution for Swift 4:



                                mapView.compassView.isHidden = true





                                share|improve this answer

























                                  1












                                  1








                                  1







                                  Here is solution for Swift 4:



                                  mapView.compassView.isHidden = true





                                  share|improve this answer













                                  Here is solution for Swift 4:



                                  mapView.compassView.isHidden = true






                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered Nov 13 '17 at 16:41









                                  mirapmirap

                                  9631020




                                  9631020





















                                      0














                                      Here swift code:



                                      let mapRotateGesture = UIRotationGestureRecognizer(target: self, action: "didRotateMap:")
                                      mapRotateGesture.delegate = self
                                      self.map.addGestureRecognizer(mapRotateGesture)

                                      func didRotateMap(gesture: UIGestureRecognizer)
                                      // Removeing compass
                                      if (gesture.state == .Began





                                      share|improve this answer



























                                        0














                                        Here swift code:



                                        let mapRotateGesture = UIRotationGestureRecognizer(target: self, action: "didRotateMap:")
                                        mapRotateGesture.delegate = self
                                        self.map.addGestureRecognizer(mapRotateGesture)

                                        func didRotateMap(gesture: UIGestureRecognizer)
                                        // Removeing compass
                                        if (gesture.state == .Began





                                        share|improve this answer

























                                          0












                                          0








                                          0







                                          Here swift code:



                                          let mapRotateGesture = UIRotationGestureRecognizer(target: self, action: "didRotateMap:")
                                          mapRotateGesture.delegate = self
                                          self.map.addGestureRecognizer(mapRotateGesture)

                                          func didRotateMap(gesture: UIGestureRecognizer)
                                          // Removeing compass
                                          if (gesture.state == .Began





                                          share|improve this answer













                                          Here swift code:



                                          let mapRotateGesture = UIRotationGestureRecognizer(target: self, action: "didRotateMap:")
                                          mapRotateGesture.delegate = self
                                          self.map.addGestureRecognizer(mapRotateGesture)

                                          func didRotateMap(gesture: UIGestureRecognizer)
                                          // Removeing compass
                                          if (gesture.state == .Began






                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Aug 27 '15 at 12:25









                                          Michał JurczukMichał Jurczuk

                                          1,84912240




                                          1,84912240





















                                              0














                                              You can hide the compass on MKMapView while rotating the map by adding below line in viewDidLoad method in all iOS:



                                              [self.mapView setLayoutMargins:UIEdgeInsetsMake(-50, 0, -50, 0)];





                                              share|improve this answer



























                                                0














                                                You can hide the compass on MKMapView while rotating the map by adding below line in viewDidLoad method in all iOS:



                                                [self.mapView setLayoutMargins:UIEdgeInsetsMake(-50, 0, -50, 0)];





                                                share|improve this answer

























                                                  0












                                                  0








                                                  0







                                                  You can hide the compass on MKMapView while rotating the map by adding below line in viewDidLoad method in all iOS:



                                                  [self.mapView setLayoutMargins:UIEdgeInsetsMake(-50, 0, -50, 0)];





                                                  share|improve this answer













                                                  You can hide the compass on MKMapView while rotating the map by adding below line in viewDidLoad method in all iOS:



                                                  [self.mapView setLayoutMargins:UIEdgeInsetsMake(-50, 0, -50, 0)];






                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered Dec 2 '15 at 10:08









                                                  sajgan2015sajgan2015

                                                  265310




                                                  265310





















                                                      0














                                                      Completely hides the compass and does not rotate the map



                                                      mapView.allowsRotating = false


                                                      Swift 4, Mapbox-iOS-SDK (4.9.0)






                                                      share|improve this answer



























                                                        0














                                                        Completely hides the compass and does not rotate the map



                                                        mapView.allowsRotating = false


                                                        Swift 4, Mapbox-iOS-SDK (4.9.0)






                                                        share|improve this answer

























                                                          0












                                                          0








                                                          0







                                                          Completely hides the compass and does not rotate the map



                                                          mapView.allowsRotating = false


                                                          Swift 4, Mapbox-iOS-SDK (4.9.0)






                                                          share|improve this answer













                                                          Completely hides the compass and does not rotate the map



                                                          mapView.allowsRotating = false


                                                          Swift 4, Mapbox-iOS-SDK (4.9.0)







                                                          share|improve this answer












                                                          share|improve this answer



                                                          share|improve this answer










                                                          answered Mar 7 at 12:53









                                                          AleksandrAleksandr

                                                          1




                                                          1





















                                                              -2














                                                              As I understand what you want is to forbid showing user's current location.
                                                              You should use @property(nonatomic) BOOL showsUserLocation.
                                                              Docs on this



                                                              Assume that @property(nonatomic) MKUserTrackingMode userTrackingMode
                                                              can't enable or disable tracking, it's just changes the mode between not following, following and following with rotating.






                                                              share|improve this answer























                                                              • No, I need to show the user location. What I don't need is the compass.

                                                                – BlackM
                                                                Oct 5 '13 at 9:46











                                                              • I found out is not appears randomly but on a specific gesture. When you use 2 fingers and the one slide right and the other left.

                                                                – BlackM
                                                                Oct 5 '13 at 9:55











                                                              • Well, now I understand what you want. The only way docs show to us to disable map's rotating using rotateEnabled. This will prevent rotate Gesture from being enabled.

                                                                – Vladislav Mazur
                                                                Oct 5 '13 at 10:15












                                                              • And if you need to rotate your map, you can add UIRotationGestureRecognizer to map's view add rotate it in way you want using [mapView setTransform:CGAffineTransformMakeRotation(rotation)]; and annotations too.

                                                                – Vladislav Mazur
                                                                Oct 5 '13 at 10:38






                                                              • 1





                                                                @VladislavMazur What is so difficult to understand? He want to disable the compass when he wants, and keep the rotation feature.

                                                                – AlexWien
                                                                Oct 11 '13 at 13:12















                                                              -2














                                                              As I understand what you want is to forbid showing user's current location.
                                                              You should use @property(nonatomic) BOOL showsUserLocation.
                                                              Docs on this



                                                              Assume that @property(nonatomic) MKUserTrackingMode userTrackingMode
                                                              can't enable or disable tracking, it's just changes the mode between not following, following and following with rotating.






                                                              share|improve this answer























                                                              • No, I need to show the user location. What I don't need is the compass.

                                                                – BlackM
                                                                Oct 5 '13 at 9:46











                                                              • I found out is not appears randomly but on a specific gesture. When you use 2 fingers and the one slide right and the other left.

                                                                – BlackM
                                                                Oct 5 '13 at 9:55











                                                              • Well, now I understand what you want. The only way docs show to us to disable map's rotating using rotateEnabled. This will prevent rotate Gesture from being enabled.

                                                                – Vladislav Mazur
                                                                Oct 5 '13 at 10:15












                                                              • And if you need to rotate your map, you can add UIRotationGestureRecognizer to map's view add rotate it in way you want using [mapView setTransform:CGAffineTransformMakeRotation(rotation)]; and annotations too.

                                                                – Vladislav Mazur
                                                                Oct 5 '13 at 10:38






                                                              • 1





                                                                @VladislavMazur What is so difficult to understand? He want to disable the compass when he wants, and keep the rotation feature.

                                                                – AlexWien
                                                                Oct 11 '13 at 13:12













                                                              -2












                                                              -2








                                                              -2







                                                              As I understand what you want is to forbid showing user's current location.
                                                              You should use @property(nonatomic) BOOL showsUserLocation.
                                                              Docs on this



                                                              Assume that @property(nonatomic) MKUserTrackingMode userTrackingMode
                                                              can't enable or disable tracking, it's just changes the mode between not following, following and following with rotating.






                                                              share|improve this answer













                                                              As I understand what you want is to forbid showing user's current location.
                                                              You should use @property(nonatomic) BOOL showsUserLocation.
                                                              Docs on this



                                                              Assume that @property(nonatomic) MKUserTrackingMode userTrackingMode
                                                              can't enable or disable tracking, it's just changes the mode between not following, following and following with rotating.







                                                              share|improve this answer












                                                              share|improve this answer



                                                              share|improve this answer










                                                              answered Oct 5 '13 at 9:30









                                                              Vladislav MazurVladislav Mazur

                                                              1




                                                              1












                                                              • No, I need to show the user location. What I don't need is the compass.

                                                                – BlackM
                                                                Oct 5 '13 at 9:46











                                                              • I found out is not appears randomly but on a specific gesture. When you use 2 fingers and the one slide right and the other left.

                                                                – BlackM
                                                                Oct 5 '13 at 9:55











                                                              • Well, now I understand what you want. The only way docs show to us to disable map's rotating using rotateEnabled. This will prevent rotate Gesture from being enabled.

                                                                – Vladislav Mazur
                                                                Oct 5 '13 at 10:15












                                                              • And if you need to rotate your map, you can add UIRotationGestureRecognizer to map's view add rotate it in way you want using [mapView setTransform:CGAffineTransformMakeRotation(rotation)]; and annotations too.

                                                                – Vladislav Mazur
                                                                Oct 5 '13 at 10:38






                                                              • 1





                                                                @VladislavMazur What is so difficult to understand? He want to disable the compass when he wants, and keep the rotation feature.

                                                                – AlexWien
                                                                Oct 11 '13 at 13:12

















                                                              • No, I need to show the user location. What I don't need is the compass.

                                                                – BlackM
                                                                Oct 5 '13 at 9:46











                                                              • I found out is not appears randomly but on a specific gesture. When you use 2 fingers and the one slide right and the other left.

                                                                – BlackM
                                                                Oct 5 '13 at 9:55











                                                              • Well, now I understand what you want. The only way docs show to us to disable map's rotating using rotateEnabled. This will prevent rotate Gesture from being enabled.

                                                                – Vladislav Mazur
                                                                Oct 5 '13 at 10:15












                                                              • And if you need to rotate your map, you can add UIRotationGestureRecognizer to map's view add rotate it in way you want using [mapView setTransform:CGAffineTransformMakeRotation(rotation)]; and annotations too.

                                                                – Vladislav Mazur
                                                                Oct 5 '13 at 10:38






                                                              • 1





                                                                @VladislavMazur What is so difficult to understand? He want to disable the compass when he wants, and keep the rotation feature.

                                                                – AlexWien
                                                                Oct 11 '13 at 13:12
















                                                              No, I need to show the user location. What I don't need is the compass.

                                                              – BlackM
                                                              Oct 5 '13 at 9:46





                                                              No, I need to show the user location. What I don't need is the compass.

                                                              – BlackM
                                                              Oct 5 '13 at 9:46













                                                              I found out is not appears randomly but on a specific gesture. When you use 2 fingers and the one slide right and the other left.

                                                              – BlackM
                                                              Oct 5 '13 at 9:55





                                                              I found out is not appears randomly but on a specific gesture. When you use 2 fingers and the one slide right and the other left.

                                                              – BlackM
                                                              Oct 5 '13 at 9:55













                                                              Well, now I understand what you want. The only way docs show to us to disable map's rotating using rotateEnabled. This will prevent rotate Gesture from being enabled.

                                                              – Vladislav Mazur
                                                              Oct 5 '13 at 10:15






                                                              Well, now I understand what you want. The only way docs show to us to disable map's rotating using rotateEnabled. This will prevent rotate Gesture from being enabled.

                                                              – Vladislav Mazur
                                                              Oct 5 '13 at 10:15














                                                              And if you need to rotate your map, you can add UIRotationGestureRecognizer to map's view add rotate it in way you want using [mapView setTransform:CGAffineTransformMakeRotation(rotation)]; and annotations too.

                                                              – Vladislav Mazur
                                                              Oct 5 '13 at 10:38





                                                              And if you need to rotate your map, you can add UIRotationGestureRecognizer to map's view add rotate it in way you want using [mapView setTransform:CGAffineTransformMakeRotation(rotation)]; and annotations too.

                                                              – Vladislav Mazur
                                                              Oct 5 '13 at 10:38




                                                              1




                                                              1





                                                              @VladislavMazur What is so difficult to understand? He want to disable the compass when he wants, and keep the rotation feature.

                                                              – AlexWien
                                                              Oct 11 '13 at 13:12





                                                              @VladislavMazur What is so difficult to understand? He want to disable the compass when he wants, and keep the rotation feature.

                                                              – AlexWien
                                                              Oct 11 '13 at 13:12

















                                                              draft saved

                                                              draft discarded
















































                                                              Thanks for contributing an answer to Stack Overflow!


                                                              • Please be sure to answer the question. Provide details and share your research!

                                                              But avoid


                                                              • Asking for help, clarification, or responding to other answers.

                                                              • Making statements based on opinion; back them up with references or personal experience.

                                                              To learn more, see our tips on writing great answers.




                                                              draft saved


                                                              draft discarded














                                                              StackExchange.ready(
                                                              function ()
                                                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19195936%2fdisable-compass-on-mkmapview%23new-answer', 'question_page');

                                                              );

                                                              Post as a guest















                                                              Required, but never shown





















































                                                              Required, but never shown














                                                              Required, but never shown












                                                              Required, but never shown







                                                              Required, but never shown

































                                                              Required, but never shown














                                                              Required, but never shown












                                                              Required, but never shown







                                                              Required, but never shown







                                                              Popular posts from this blog

                                                              Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                                                              Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                                                              Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved