Hi, I'm having UIImageView, few lables, buttons etc in a view. Currently I have implementation for portrait mode. When orientation of iphone is changed, I just want to rotate only image view. Rest all other controls should not change. How can I implement the rotation of only image view?
views:
61answers:
1
                +1 
                A: 
                
                
              I had to do something very similar recently. What I did was disable auto rotation and then used the device notifications like this:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
- (void)didRotate:(NSNotification *)notification {  
    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    switch (orientation) {
        case UIDeviceOrientationUnknown:
        case UIDeviceOrientationFaceUp:
        case UIDeviceOrientationFaceDown:
            return;
            break;
    }
    // Do something
}
You will need to handle some situations like quick rotations etc. Let me know if you need more info.
                  v01d
                   2010-06-20 11:08:18
                
              Thanks for the reply. But needs little clarification. Do I have to create different view class that inherits from ImageView and handle it or I can handle "didRotate" in viewController itself?
                  Satyam svv
                   2010-06-21 06:09:34
                My suggestion would be to handle this in the view controller. Perhaps setup the observer in your viewDidLoad. The notifications will be sent immediately for _any_ orientation changes. So I save the orientation change and set the animation on it's way. If there is another orientation change during the animation I start the animation all over again until there are no changes.
                  v01d
                   2010-06-21 10:41:54