Implementing a horizontal compass on the iPhone - algorithm?

Posted by Andrew Johnson on Stack Overflow See other posts from Stack Overflow or by Andrew Johnson
Published on 2010-03-27T01:47:54Z Indexed on 2010/03/27 1:53 UTC
Read the original article Hit count: 437

Filed under:
|
|

A horizontal compass looks something like this if you are facing due East (90 degrees).

85----90---95

If you were facing due 355 degrees northwest, it would look like this:

350----355---0

As you turn the compass, the number should cycle from 0 -> 360 -> 0

So, my question is, how would you implement a view like this on the iPhone? I had a couple of ideas:

  1. Make one long image with all numbers and tick marks, and shift it left/right when the compass heading changes

  2. Create pieces of the view as tiles and append them when the compass heading changes.

  3. Create a line of tick marks that shifts with the compass heading, and just write numbers on it as needed.

How would you attack this problem? Im mainly looking for algorithmic advice, but if you ave code or pseudo-code to demonstrate, that would be helpful too.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about cocoa-touch