views:

705

answers:

2

Is there a way to receive a notification when the iPad gets orientation locked? When the orientation lock is set on or off, it does send a receivedRotate: notification, but I need a way to be able to distinguish normal rotations from lock "rotations".

The problem is I am rotating things in my view when the rotation changes. When the lock is activated, the iPad sends a receivedRotate: with UIInterfaceOrientationPortrait.

I've looked in UIDevice for something like isOrientationLocked, but with no success.

Thanks for any clues on this.

EDIT: I can't comment so I'll just edit..

When the iPad orientation lock is switched ON, it does send a notification that the rotation changed to portrait for some reason. This causes the elements to rotate since they rotate with any orientation change. This is what I want to prevent.

EDIT2: Yes, the iPad shouldn't send a portrait notification but it does. After this portrait notification the iPad stops sending notifications, which is the way it should be. It's just the initial notification that is in the way.

I cannot use the accelerometer because I still want to be able to use the orientation lock's locking feature. Maybe I would use the accelerometer if I had some way of knowing when the iPad was locked.

EDIT3: receivedRotate: is called with UIInterfaceOrientationPortrait for all orientations.

A: 

Just to be clear, are you only using the rotation notifications to determine your rotations? You are not pulling data from the accelerometer or the like to get your orientation?

One other thing is that the lock is just that, a lock, it should not force you into portrait mode if you are in landscape. It should just keep you in landscape.

So, guessing from what you are doing I might suggest that you really do not want to be using the notifications as the basis of your interface but rather the accelerometer data directly.

As a newly minted iPad owner I might wonder what you are doing since I see the lock as a way to keep the orientation the way I want when my physical orientation is not "normal" like laying on the couch.

Ukko
+1  A: 

Apparently it's working now.

I recently jumped back into my old project after installing the latest XCode & iPhone SDK and I no longer receive UIInterfaceOrientationPortrait when the lock is switched on. Haven't changed my code at all so it must be Apple.

vakio