Orientation not working in iPad - ios

I made an iPad application in which I want to support orientation, so I've written this code:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
//return YES;
return (interfaceOrientation==UIInterfaceOrientationPortrait||interfaceOrientation==UIInterfaceOrientationLandscapeLeft||interfaceOrientation==UIInterfaceOrientationLandscapeRight);
}
I've created a few tables in portrait mode, so when I rotate my app, the tables still comes according to portrait mode only, but the table inside my view doesn't autoresize.

You need to make sure the table view itself is set to expand and contract in both directions when autoresized - this is easiest set in IB by clicking on the table view, then clicking on the ruler sidebar header tab, then making sure that all of the autoresizing options are turned on - resizes both directions, sticks to all corners.

Related

One landscape view for whole app

How to setup just one landscape view for whole app? I want to show only one view (qrcode) when phone is rotated independently in wich view this happened. What is the easiest way to do it?
My app is in portrait and I want show users code when it rotated to landscape in whatever view this was done.
See this answer. Just untick Portrait and tick on whatever Landscape orientation you want.
http://stackoverflow.com/a/29791531/7198143
Edit:
You should use Autolayout in your Storyboard to set up the right constraints so even in Landscape mode, the label for the code shows up. See this tutorial for more info.
Autolayout tutorial

iOS View does not change orientation on orientation change

I have a root view which contains a scroll view which contains a (content) view. The content view contains many child controls. Using the simulator, when I change orientation, none of the views, including the scroll view changes orientation. For example the image below starts out in portrait mode and all controls are played out correctly, but moving to landscape mode just shows portrait mode horizontally:
All of this was laid out using Interface Builder, so I don't have much code in the control view file besides some IB outlets to the controls.
Is there some sort of constraint that is preventing the reorientation of all the controls and views? Or do I always have to lay these out manually on orientation change?
First you need to check you have allowed the app to rotate by checking the orientations you want are ticked:
Click on the top-left corner (Show the Project Navigator)
Select the name of your project
See what is under General->Deployment Info->Device Orientation.
Adjust the tickboxes accordingly.
Update:
Also slide up on the simulator and check that rotation isn't locked for the device.
Try putting this in your AppDelegate/view controller:
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
(I don't think it's a constraint/layout issue as the status bar isn't even rotating)

Allow subviews to autoRotate even though parent views are locked in portrait mode?

I am developing an app in IOS6. I am using storyboard and in my summary I have only portrait mode checked for Supported Interface Orientations. This allows my entire app to be locked into portrait mode without any extra programming.
In one of my viewControllers I have a subview (UIView) that is hidden and won't appear till a button is clicked. Once the button is clicked and the subview appears, it takes over the screen and displays images in a slideshow. I would like to make this subview have the ability to autoRotate because some of the images are in landscape. Is there a way to programatically allow this subview to be able to do this, even though the rest of the app is locked in portrait mode?
If you want to enable landscape in a single view controller and disable it elsewhere everything gets a bit complicated.
Essentially you need to set up all your view controllers to only allow portrait via supportedInterfaceOrientations. Then on your single view controller that you want to allow landscape on you can enable it via supportedInterfaceOrientations.
Lastly you then check all the supported orientations for your target.
Its a bit ugly but it works.

iPad - Different designs for landscape and portrait mode

I'm making an application for iPad in Xcode in template Master-detail application. I need to do a design for portrait mode and another for landscape mode. My first idea was make two UIViews and make a rule: if portrait, show View1, if landscape, show View2. But I have text fields in it and when the user will be typing something inside and then rotate the device, text will be deleted, because it will be another UIView... Can anybody help me, how to do it, please?
You can have one view and use springs and struts or use autolayout.
You can also add views and hide/show them based on the orientation change.
You can change the size and position of the view on orientation change.

iPad adding view and then telling it to resize based on orientation mode?

NEW EDIT:
I have narrowed my problem to this - i have a view that i add to my main view. That view is nib file in portrait orientation. That view can be added both in landscape or portrait mode. After adding it as subview how do i tell it, device is now in landscape mode, you should autoresize to fit?
OLD:
/*
I have a view, that is loaded via [NSBundle mainBundle] loadNibNamed. When button show is pressed view should show, and likewise when button hide is pressed view should hide. And this works ok.
Problem is with when device orientation is changed (lets say from portrait to landscape mode). If view is shown it resizes ok, and everything works fine. But if view is hidden, and i rotate the device and press show, view is shown, but not adjusted to new layout. It retains its original dimensions.
It is as automatic resizing is only applied to visible components. Is there some way to force resizing of the view?
*/
When you add your view, use the following:
[subViewFromNib setBounds:[viewYouAddedSubviewTo bounds]];

Resources