IOS6 Update view when interface orientation change - iphone

I need to reposition a UIPopoverController when interface orientation change. In io5 I just did everything in:willRotateToInterfaceOrientation
I know I can listen to UIDeviceOrientationDidChangeNotification in IOS6, but I only want interface orientation calls.

The ideas behind ios6 rotation are that some views, like popovers, dont really have an orientation. as they dont fill the screen.
To re-layout the view as the size of the popover changes layout your view in -(void)viewWillLayoutSubviews in your popover's content view controller and ajust the views as needed to the new size. Animatable changes are animated.

Related

iPhone Orientation Change

I know how to do an orientation change, but lets say you have a view with buttons, labels, ect. The autoresizing distorts and makes the view look strange. What's the accepted way to do this, do I just create a portrait and landscape view. If so where would I actually do the swapping of these views.
Do all kind of resizing and reposition in your layoutSubviews method of UIView.
Once the orientation is changed, your layoutSubviews would be called then you can know the current orientation by using UIDevice class. and reposition your views child accordingly
UIDevice property to be used for getting current orientation .
#propertyic,readonly) UIDeviceOrientation orientation
My sandbox app:
https://github.com/comonitos/programatical_device_orientation
The solution is easy

tabBarController + changing orientation problem

I have a TabBarController with 4 views, and one of them is a scrollView. If i load this view, and then change the orientation of my device from portrait to landscape, the scrollview responds to the touches only 'till the pixel 320.
If later i go to another view, and then come back to the first, the scroll view works well even in landscape.
How can i adjust this?
Your scroll view is probably not set to automatically adjust its height and width. If your view is built with Interface Builder, use the Autosizing section of the Size Inspector to set the struts & springs. Otherwise, if you're building your view programmatically, you'll need to set the autoresizingMask property to something appropriate.

Resizing content in a UIScrollView

I am creating a scrollview programmatically and adding subviews to it programmatically. The subviews are created programmatically as well.
I am just wondering how to rotate / resize the subview so that it remains visible in landscape mode.
I have set the scrollview to autorotateSubviews:YES and in my subview i have set the mask to be flexiblewidth|flexibleheight is this correct?
I am used to doing this in IB with the springs and struts section of the inspector.
Thanks
Your scroll view is probably contained in a view witha corresponding controller that receives willAnimateRotationToInterfaceOrientation:duration: and didRotateFromInterfaceOrientation: notifications. Use these opportunities to resize the subviews of the scrollview.

preventing a specific view from auto rotating... is that possible?

I have a view based app. Its self.view has several subviews and shouldAutorotateToInterfaceOrientation is returning YES.
When I rotate the device, all views rotate as expected.
Is that possible to prevent a subview from auto rotating even if the view's parent is auto rotating?
Keep in mind that it's the view controller that controls what happens during rotation and not the view itself. You can't stop a subview from rotating by setting a property, or something relatively easy, if its parent view's UIViewController is set to auto rotate. You can, however, have sibling views where one rotates and the other doesn't. It's probably possible to layout your views the way you want but not have the one that shouldn't rotate as a subview of a rotating UIViewController.
You could probably write some code that will reorient a subview so it appears not to rotate when the parent view does rotate, however.

Changing view size when orientation changes

I want my UIView subclass to behave so that when it is fitted in portrait orientation is has a certain size and another size when fitted in landscape mode.
Is it possible to have the view indicate to the view controller that's resizing it when the orientation changes that it has this "ideal size"?
To clarify, I'm confident that this is not something that can be done with the autoresizing mask. I also thought that sizeThatFits: would be what I need but I didn't see it get called when the orientation changed.
I'm also aware that I can get this done by overriding layoutSubviews of the superview (or maybe some other method of the view controller but I would like to have this behavior embedded in the view to facilitate reuse.
You get several messages when the device rotates:
- shouldAutorotateToInterfaceOrientation:;
- willRotateToInterfaceOrientation:duration:;
- didRotateFromInterfaceOrientation:
You can use these to re-layout your view when the user rotates.
If you don't want to use a view controller, you can register for the UIDeviceOrientationDidChangeNotification notification.