In iOS 8 and iOS 7, iPhone rotation locking has been moved to the Control Center. To enable rotation lock and prevent the screen from automatically changing orientation when the iPhone is turned:
To access Control Center and lock rotation in iOS 7/8 follow these steps:
1. Swipe up from the bottom of the home screen to bring up Control Center.
2. The top row of the Control Center shows 5 circular toggles.
UPDATE: iOS 4 features a built-in rotation lock function. Find out more information about how to use rotation lock here.
Some iPhone applications have preferences to set an accelerometer lock under Settings. When rotation is disabled, the orientation of the app stays fixed in one direction no matter which way the iPhone is turned.
Most commonly used apps such as Safari, Messaging, Mail and iPod do not have this feature available in the preferences. In contrast, orientation can be temporarily fixed when viewing photos on the iPhone Camera Roll or Photo Library.
Some iPhone applications have preferences to set an accelerometer lock, which keeps the orientation of the app in one direction no matter which way the iPhone turns. Unfortunately, most commonly used apps do not have this feature.
Rotation can be switched off when viewing photos on the iPhone Camera Roll or Photo Library. When viewing a photo, hold down with one finger on the photo as if you're trying to copy the image.