The compass feature built into an Apple iPhone should normally detect the earth's magnetic field to point you in the right direction. If you suspect something like a large metal object is interfering with the compass, you can usually just move away from the object to have the compass recalibrate itself. To be completely certain the compass is operating properly, you can force recalibration by putting the iPhone near a large metal object or a small magnet like a fridge magnet.
Video of the Day
Launch the Compass app on the iPhone. Place the back of the iPhone on a desktop computer case, against a refrigerator, filing cabinet or other large metal object until the Compass Interference screen appears. Metal often interferes with the compass and forces it into recalibration mode.
Move the magnet if needed until the Compass Interference screen appears.
Move the iPhone away from the metal object and then hold the iPhone horizontally away from your body at arm's length. Move the iPhone slowly in a figure-eight motion. The iPhone compass recalibrates within two or three seconds.