I have a problem with my Samsung Galaxy Ace is locked in landscape mode, that is to say when it is rotated 90° it is blocked in this position.
The below solution may work on other Samsung phones:
From idle screen (Home) slide down the top window, or press notification icon and once the open window, tap on the "Auto Rotate" key to activate it (normally it will turn green in color)
Press the menu button, then settings and then display. You'll noticed that the Auto Rotate option is already checked! Scroll to the "horizontal calibration" section and when asked place the phone on a flat surface such as a table and then you press calibrate.
Now check if your phone auto-rotate feature is working properly.
If the above solution doesn't work, you can try to restore your phone to factory settings.