iPhones can’t always figure out which way is up. There are plenty of times when you’re lying down or leaning back that the phone’s screen keeps shifting from portrait to landscape – now it’s portrait... and back to landscape. There is a way to stop this constant screen rotation.
First, double-click the iPhone home button. This will bring up a list of recently opened apps. Swipe from left to right. That will reveal a set of music controls – stop, play, skip track, etc. Ignore those for right now because we’re interested in the far-left button – that gray icon with a circular arrow. Touch the icon and a message will come up reading, “Portrait Orientation Locked.” Now, it doesn’t matter if you’re reading a text message sideways on a roller coaster, your screen will stay vertical.
If you can’t remember whether your screen has been locked or not, check for the lock icon next to your battery indicator in the top-right corner. Curiously, this trick only works vertically. You can't lock it to a horizontal orientation.