When an iOS device rotates, how do I change the orientation of only one item?

I would like to be able to handle orientation changes in my current iPhone application. The problem is that I do not want my controller to be able to rotate or resize. When the orientation of the device changes, I just want one element of the user interface to rotate 90 degrees on the screen.

The Apple camera app is a great example of this — when you change the orientation of the device, all the buttons rotate, but the view itself does not rotate.

I suppose I could just resize the view, move all my elements around, and then animate the buttons, but I feel that there should be an easier way to do this.

Thanks in advance.

+5
source share
2

1) 2 willRotateToInterfaceOrientation: .

2) .

+5

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
if(interfaceOrientation==UIInterfaceOrientationPortrait || interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown)
    {
        //Change frames as per orientations
    }

    else
    {    
          //Change frames as per orientations
    }


    return NO;
    }

, . Constants .

EDIT: NSNotification .

UIApplicationDidChangeStatusBarOrientationNotification

, .

NSNumber, UIInterfaceOrientation (. UIInterfaceOrientation). UIApplicationStatusBarOrientationUserInfoKey

Available in iOS 2.0 and later.

UIApplication.h

+2

All Articles