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

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.

Related

xibs displayed incorrectly after iOS 7.1 update

So our app is built using XIB interfaces, not story boards. We have XIBs for iPhone and iPad.
Since the iOS7.1 update the, iPhone xibs are now bigger in interface builder and far too tall when deployed on a device.
The height is all wrong, the XIB is far too tall now. For example, backgrounds appear to go way outside the View when set to fill. When deployed on the phone everything is shifted down about the height of the top nav bar.
If I add/remove Top/Bottom Bars for the View in Interface Builder things shift around but not in a way that makes sense. My app has a nav bar, if I tell the interface builder it has a nav bar then the height of the xib grows a further 80 or so pixels. If I tell the interface builder it has no nav bar, everything shifts up properly but the height of the View is still so tall that backgrounds and stuff near the bottom go off screen.
So for the very vague issue but we are pulling hair over this.
UPDATE
- It seems Opaque Navigation Bar fixes half the problem. We had every interface set with a Translucent Nav Bar. Those do not appear to take up space in IOS7.1 but they did in IOS7.0.
The problem now is still height. It still seems internally the height is broken or starts from a new origin.
In view did load, on a view with a opaque nav bar, on iPod Touch:
self.view.frame.origin.y is showing 0
self.view.frame.size.height is showing 256
Nav bar origin.y = 20
Nav bar size.height = 32
This totals 308, missing 12 pixels.
Create auto layout constraints in IB or programmatically that align the top of the main view in each XIB file to the "top layout guide" and bottom of the views to the "bottom layout guide." This solved a very similar problem when moving from iOS 6 to iOS 7 in several of my apps.

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.

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.

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.

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.