View shows only half of width in landscape mode - iphone

I have one view controller,in that i have 1 UIButton ,when i click on that button one view opens ,but when i move it to landscape mode at that time the view shows only half of width not full.what should i do?????
Thanks and welcome for answers

You may need to set the autoresizing properties, i.e.
myView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
You should probably call setNeedsDisplay on the view after changing the orientation.

Related

Display a control in both orientations

I've got a button designed on Portrait Orientattion, when I switch to Landscape it doesn't appear, what should I do so that it stays all the time?
Make sure you set the proper AutoresizingMasks for your UIViews. For example, it might be that your button has a y-coordinate that is larger than the device's width and has a fixed top resizing mask, so if you turn the device to landscape mode it gets clipped. Doing this...
button.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
...will cause the button to shrink its top margin, moving on screen.
In your comment you mentioned that this is a split-view app, if your button is in the root view controller of the split view, you should probably add support for restoring the root view controller as a popover.

ipad: problem in landscape and portrait orientation

I am completely new to iPad development and facing this issue:
In added a View, "LoginView", as a subview of "detailView". I displays fine in portrait mode, but in landscape mode its getting shifted to lefthand side and covers only half of the screen.
Please help me and provide solutions for these two:
1) "LoginView" should cover the complete screen in landscape mode.
2) After LoginView, if login is successful I add 'SearchView' to 'LoginView' as subview, but this screen is hiding the toolbar(and thus toolbar button) in both the Portrait/Landscape I want that toolbar to be visible.
3) Again this 'SearchView' is shifted to left of the screen I want this to be on righthand side.
If you're using Interface Builder then open inspector and go to the size tab.
You can define how the view should resizing.
If you are programmatically designing your view then you can have define the autoresizing mask with:
// eg. of a possible combinaison
view.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleRightMargin;
/* With a possible combinaison of those value:
UIViewAutoresizingNone
UIViewAutoresizingFlexibleLeftMargin
UIViewAutoresizingFlexibleWidth
UIViewAutoresizingFlexibleRightMargin
UIViewAutoresizingFlexibleTopMargin
UIViewAutoresizingFlexibleHeight
UIViewAutoresizingFlexibleBottomMargin
*/
Check the views auto-resizing property

Why is a SubView resizing after InterfaceRotation?

I'm adding a subview to the UiView of my mainviewcontroller, that is presented in a similar way as a UIModalViewController with the Formsheet-style. (so it doesn't fill teh whole screen)
No if the device rotates the subview somehow gets resized to fill the whole mainview...
Even if I manually set:
subViewCtrl.view.autoresizingMask = UIViewAutoresizingNone;
it still autoresizes.
Why can't it simple stay in the middle as any other subview would?
Ok, I figured it out myself.
I accidentally did
[self.view.superview addSubview:rowCtrl.view];
so I changed this too
[self.view addSubview:rowCtrl.view];
and it worked as intended. Thanks anyway!
Of course, then one also has to set
rowCtrl.view.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
otherwise it doesn't get centered properly when the interface rotates.
Is the view resizing, or is the view staying the same size while the dimensions of the screen change? You may want UIViewAutoresizingFlexibleWidth and/or UIViewResizingFlexibleHeight. If you use those values then your subview will resize to remain a constant distance from the edges of the screen; your view will change sizes, but remain centered.

Auto Resizing with Interface Builder and Code?

I want to use auto resizing mask in iPhone to adjust view in landscape and portrait mode. The problem is when I apply width spring from Interface builder, the button changes its size proportionally. But when I apply the same spring by code i.e.
[self.view setAutoresizesSubviews:YES];
[testButton setAutoresizingMask:UIViewAutoresizingNone];
[testButton setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
the button doesn't show the same behavior.
Auto resizing applied on button from Interface builder:
original button size: 120 width and 37 height
landscape mode button: changes size proportionally
Auto resizing applied on button from Code:
original button size: 120 width and 37 height
landscape mode button: changes size by keeping same left and right margins in both Portrait and landscape mode.
The mask applied from code doesn't seem to work correctly as the size of button created from code comes out to be greater.
My views are complex that is why i don't want to set the frames of each subview on the View.
Anyone with same issue!!!
Thnx for responding guys, by the way I have solved my issue. There was nothing to do with the link with the interface builder. Actually while creating your view without interface builder, if you want the subviews to be auto re-sized; You have to set springs and struts in a single line using the bitwise OR connector. The code I used for re-sizing my view is:
[appLogo setAutoresizingMask: UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];
Check 2 things.
1. Connection of IBOutlet
2. Also check that you have created the #property of the IBOutlet of view you have created.
Hope this solve the issue.

IPhone how to properly resize view when rotating device

I have been trying to resize my view inside a view Controller with no luck so far. Basically I have a button at the very bottom of my view and when the orientation changes from Portrait to Landscape the button is no longer visible, because its just too far down now.
How can I resize this view so that when the orientation changes the button is still visible?. I have tried setting
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
and basically every other possible combination, with no luck so far. I know I can do this by manually repositioning the button, but is there a better way to do this?.
Thank you.
-Oscar
The view containing the button must be auto-resized using your mask (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight).
On the containing view autoresizesSubviews must be set to YES.
The button must use UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin.