How to lock device's orientation ?

How to lock device's orientation ?
0.0 0


I want to lock device’s orientation to one way (the same functionality to physically turn on lock rotation button beside the iPad’s device), I did with the following code.


But as long as I turn around the device, the screen rotates. The above code only effects the way the objects in the game, not prevents the device’s screen from rotating.

Any suggestions ?

FYI: I tested it on iPad.