Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone SDK: Locking the orientation

I've seen it on a previous app (forgetting the app name), where you could lock the current orientation of the screen.

Is there an easy way for this to be done, for example, simply using a button.

like image 497
Domness Avatar asked May 23 '26 06:05

Domness


1 Answers

Just add an ivar to your app delegate that can be set by pressing the locking button. Then in all of your view controllers you can just check the ivar in the app delegate and respond to the

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

message according to your orientation ivar

like image 88
nduplessis Avatar answered May 24 '26 20:05

nduplessis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!