Display a control in both orientations - iphone

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.

Related

When on iPhone 5 landscape mode, the button on the right of navigation bar stops working, how to fix it?

When updating my old program for iPhone 5's 4 inch screen, I found that the navigation controller keeps to its original 3.5 inch screen size and refuse to stretch to fit the 4 inch screen even when its view controller's view and tableview controller's view are all stretch to fit the 4 inch screen. Because the navigation controller's view is not visible during normal use, people may miss it. Because it refuses to fit the new 4 inch screen, when in landscape mode, the screen go beyond the navigation controller's view width and the right button fall off the boundary and becomes unresponsive. In order to show the situation above, I set the navigation controller's view's background color to semi-transparent red and the table view's background color to semi-transparent blue. as shown in the screen shoots below. The question is, how to fix the problem. the plus button are not responsive when in landscape mode, but in portrait mode, it works fine.
Either your navigation controller’s view or, more likely, the window that contains it, are not getting set up with the correct frame. If you’re creating the window in code, make sure you’re using UIScreen -applicationFrame or -bounds rather than a hardcoded (320, 460) or (320, 480); if you’re using a NIB, check your autoresizing masks and layout settings.

How to get an image taken from the camera to take up the entire screen

I have dragged a UIImageView onto the UIViewController window in storyboard. I used the handles to make it take up the entire window. I set the mode of the UIImageView to "Aspect Fit". My goal is for the picture to take up the entire window when the iPhone is held in the same orientation that the image was taken.
But for some reason there's a little bit of space above and below every image.
Also I have it set up for the navigation bar and status bar to disappear when the user touches the image by using a hidden UIButton. This works okay except that the image shifts down when the navigation and status bars come back into view. The image only shifts down when I have this code:
self.navigationController.navigationBarHidden = YES;
self.navigationController.navigationBarHidden = NO;
which I use to get the navigationBar to redraw itself below the statusbar because sometimes the navigationbar will be drawn underneath the statusbar (this happens when making the navigationbar and statusbar reappear at the same time.)
How can I make my images display full screen without all these quirks?
EDIT:
I think it may have something to do with this:
The camera's aspect ratio is 4:3 and the screen's aspect ratio is 3:2.
So there is simply no way for the camera picture to fill the screen
unless you're willing to crop is to 3:2. To do that, apply an
appropriate scale transform.
is it possible to apply an affinetransform to an image in a uiimageview?
You'll want to set wantsFullScreenLayout to YES on your instance of UIViewController. From the documentation for wantsFullScreenLayout.
When a view controller presents its view, it normally shrinks that
view so that its frame does not overlap the device’s status bar.
Setting this property to YES causes the view controller to size its
view so that it fills the entire screen, including the area under the
status bar. (Of course, for this to happen, the window hosting the
view controller must itself be sized to fill the entire screen,
including the area underneath the status bar.) You would typically set
this property to YES in cases where you have a translucent status bar
and want your view’s content to be visible behind that view.
If this property is YES, the view is not resized in a way that would
cause it to overlap a tab bar but is resized to overlap translucent
toolbars. Regardless of the value of this property, navigation
controllers always allow views to overlap translucent navigation bars.

Iphone View Rotation not functioning properly

I have a simple 1 screen app, with 1 View.. the view contains
a button, an textbox and a button across the top
A segmented controller across the bottom
and a MapView in between.
In portrait mode all is right with the world.. So I decided to begin to allow Orientation change...
in IB all views and elements and even the root window have autoResizeSubviews set
in My AppDelegate and my viewController I have also programatically added SetAutoResizeSubviews to yes explicitely I have set the autoResizingMask in the Root Window and the View Controller to FlexibleWidht | Flexibile Height
I have added the shouldAutorotateToInterfaceOrientation in my ViewController to always return true.
Yet, it doesn't work.. Or should I say it doesn't rotate properly.. in both portrait modes everything looks great, but both landscape modes, things don't get laid out or resized properly.. Basically all I see is the mapview, and its size gets slightly wider, but not much than the portrait mode, and it doesn't fill up the screen top to bottom.. all other interface elements with the exception of one button are invisible and it appears on TOP of the mapview.. as thought it just happened to be layed out over the view by coincidence than any design.
Anyone have any ideas what I am missing, or why?
Thanks in advance
You say "I have set the autoResizingMask in the Root Window and the View Controller" but that is a red herring. It is the buttons, the text box, the segmented controller, and the map view that have to have the correct autoresizingMask. If this view is being designed in the nib, you can set the values there and then turn the orientation right there in the nib and see what happens.
If you are unable to work out good autoresizingMask values for all those interface elements, implement didRotateFromInterfaceOrientation and perform the layout alterations in code when called upon to do so.

Button disappears when iPhone rotates

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.

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.