views:

928

answers:

4

OK, bear with me.

I have a UIView which is supposed to cover the whole device (UIWindow) to support an image zoom in/out effect I'm doing using core animation where a user taps a button on a UITableViewCell and I zoom the associated image.

The zooming is performing flawlessly, what I haven't been able to figure out is why the subview is still in portrait mode even though the device is in landscape. An illustration below:

http://www.weeshsoft.com/images/IMG_0482.jpg

I do have a navigation controller but this view has been added to the UIWindow directly.

Signed, Baffled in Atlanta

A: 

This is because as you mention your view has been added directly to the UIWindow, therefore when the method to rotate is called for the navigation controller nothing happens to the uiview. The UIView would rotate if it was a subview of the view controller view. If for some reason this cannot be done. Then you could override this method:

// This method is called every time the device changes orientation
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
}

And every time your orientation changes also change your view orientation.

OscarMk
+1  A: 

Never figured this out so I added a nice animation effect instead.

Ken
A: 

I had a similar problem with views being added directly to a window. Maybe this will help: http://stackoverflow.com/questions/2659400/automatically-sizing-uiview-after-adding-to-window

Kristopher Johnson
+1  A: 

You can read about some of the possible causes here http://developer.apple.com/iphone/library/qa/qa2010/qa1688.html

In your situation its probably the fact that you are adding the view as another subview to the window. Only the first subview gets the rotation events. What you can do is add it as a subview of the first window subview.

UIWindow* window = [UIApplication sharedApplication].keyWindow; if (!window) window = [[UIApplication sharedApplication].windows objectAtIndex:0]; [[[window subviews] objectAtIndex:0] addSubview:myView];

dizy