Button disappears when iPhone rotates - iphone

In my application, I have a series of tables which leads up to an image. In portrait mode, there is a button in the bottom right hand corner, and when I select this the screen flips and I can make notes.
When I turn iPhone to landscape mode, this button disappears completely.
Any ideas?

If you're setting up the view in code, use the autoresizingMask property. This is what is being set by the constraints in Interface Builder. However, it's a little backwards from what you see in Interface Builder. If you want it to stick to the lower-right corner, set view.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin (which is equivalent to enabling the springs on the right and bottom in IB. Flexible width and height, on the other hand, work as you would expect.
As long as the superview has autoresizesSubviews set to YES (the default), it will reposition automatically when you rotate.

That's probably because the button is just off screen. You need to constrain it in Interface Builder (on the size/layout tab of the Inspector Window) or use setFrame: to reposition it when the app rotates and then again when it rotates back.
Anytime the device rotates, it will reposition items based on either code or how it is constrained in Interface Builder. If you don't control the repositioning, then it might give the appearance that it magically disappeared.

Related

How to anchor buttons to bottom of view when rotated?

I have a view on an iPad that contains one UIWebView consuming most of the display and two buttons at the bottom. When I rotate left, the buttons end up on the right and I have a gap on the left not filled by the uiwebview.
What I would like is for the buttons to always be on the bottom and for the uiwebview to fill the remaining space. I have tried various options with autosizing in interface builder without success.
Is this possible with autosizing? It seems like a fairly simple scenario.
Set the button's autoresizingMask to UIViewAutoresizingFlexibleTopMargin and the web view's to UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight.

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.

How to rotate my view-based app to the new interface orientation?

I have a simple view-based app from that template. It has nothing else in there, only one UIButton.
When the device rotates, I want that button to be re-layoutet in such a way that it fits the width of the screen automatically. It has a margin of 20 points left and right, which should always remain the same.
I am not sure what template you are referring to. But if you are adding the UIButton in Interface Builder, take a look at the inspector. What you would need to do is to make sure your UIButton autosizing struts and springs are properly set. There is a preview button that will show you how the button will be autosized if the view changes.

iPhone resizing UIView on rotation problem

I setup in IB in portrait mode my main view (for iPad). I have a toolbar, a map view (x=0, y=44, w=768, h=774) and a footer view (x=0, y=818, w=768, h=186).
When I rotate the iPad, I want the map to stay on the left side and be resized vertically to fit the view (x=0, y=44, w=756, h=704) and put the footer view on the right side (x=0, y=818, w=768, h=186) and extend vertically too.
Anyway, the effect is exactly the same as the WeatherBug application. I don't know how they do that, but their view containing the information is rotating by 90 degrees with the UIScrollView and UIPageView, I have basically the same needs and really don't know how to make this. Do they have everything in the same xib? I'm so confused...
Please tell me if you know how to do/organize a such view!
Thank you...
If you want the map to stay against the left side and be able to resize vertically set its autoresizingMask as such: mapView.autoresizingMask = UIViewAutoresizingMaskFlexibleRightMargin | UIViewAutoresizingMaskFlexibleHeight;
I don't understand how you want to footerView to resize through (y=818 in landscape mode is out of the visible view).
You should read the UIView reference, specifically the part regarding autoresizing mask (link: http://developer.apple.com/iphone/library/documentation/uikit/reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instp/UIView/autoresizingMask )

Tab views on iPad not resizing

My view doesn't stretch to fit the current orientation!
I am creating a tab bar application. I replicated the sample one that you create when you "create a new tab bar application". Everything works except when I change the orientation of the iPad it rotates the view, the tab bar stretches out on the bottom, but the view doesn't resize. Basically if you start in landscape then rotate to portrait, it rotates but the view is still landscape shape even though it rotates.
My tab bar has two tabs (just like the sample application) and so I compared mine against the sample which works property by property. One difference is I noticed my FirstView in IB under the resizing area doesn't show the resize arrows left/right up/down. In other words it isn't marked to auto fill its container. The sample's FirstView and SecondView DO have these arrows. But I can't turn them on!
I even tried creating a fresh new view but I still can't press these arrows on. what am I doing wrong here?'
Thanks a lot.
The solution is this:
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
Do this in viewDidLoad. There must be a bug in IB.
Another answer is turning off any simulated tabbars, nav bars, or status bars on the view in Interface Builder. Go into the autosizing area and turn on the auto grow arrows. Then turn back on the simulated user elements.