0

How do I make a compass show up in my app? There is no compass in the object library that I can just add to my view. So I figured that a compass must be added via code. I have been looking at multiple tutorials, but none of them seem to actually have any compass components. One of the tutorials: http://www.iphonedevsdk.com/forum/iphone-sdk-development/42992-how-do-i-make-compass.html

I have done everything in it, however nothing shows up. As the same for other tutorials. I had been reading as well saying that I need to enable something in my .plist, but they don't actually say what. Any tips, explanations or tutorials would be amazing!

A.sharif
  • 1,977
  • 1
  • 16
  • 27

1 Answers1

3

It's not really a drag-and-drop component in xcode. You need to:

  • Start listening for magnetometer data
  • Convert the data from radians to degrees
  • Create a view with an image for your compass needle
  • Create a timer that every so often tells the compass needle view to animate smoothly to the new magnetometer reading

That's the theory behind it. I couldn't find any simple tutorials when I built mine a few months ago.

Jezen Thomas
  • 13,619
  • 6
  • 53
  • 91
  • I wouldn't worry about a timer - just set a required accuracy and update the view in the `didUpdateHeading:` method. – Abizern Feb 06 '12 at 19:24