Teddy13
Teddy13

Reputation: 3854

Detect vertical or horizontal position iOS

I have an iPhone 4 and I would like to detect whether the phone is vertically straight (see first image) or horizontal (see second image). I am not talking about portrait vs landscape view detection.

I am new to iOS development and I think what I am looking for is the accelerometer (specifically the pitch property perhaps) or gyroscope. I have looked online and I am not quite understanding the code or whether I am looking for the right properties. Can someone please tell me how this can be done?

Thank you!

enter image description here

enter image description here

Upvotes: 0

Views: 832

Answers (1)

Birdy
Birdy

Reputation: 355

Try the accelerometer api and check the position of the phone.

here is a tutorial: http://tech.pro/tutorial/968/iphone-tutorial-reading-the-accelerometer

Upvotes: 1

Related Questions