Why does the compass seem to work only when I’m moving?

For the iPhone 5, 4S, 4, 3G, or the 3GS while the compass in satellite mode, the compass on the MotionX-Compass page acquires information from “orderly changes in position”.

Steady directional motion improves accuracy. A sustained speed of a few mph or km/h is all that is needed to provide an accurate heading.

In satellite mode (which is the only option for the iPhone™ 3G), at slow speeds, heading information is unreliable since it does not use a magnetic compass.

To change compass modes simply touch the center of the compass. This will toggle the compass between GPS mode and Magnetic mode.