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

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.

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.

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.

Transparency for top UIView not working

In a UINavigationController I have a UITableView. I use a settings-button to allow users changing some table settings.
When the settings-button is tapped I push a new view onto the navigation stack.
This new view has the following view structure
-> UIView1 411 x 320 px (backgroundColor supposed to be transparent) !!!!
-->> UIView2 270 x 300 px (backgroundColor grey)
--->>> Screen elements
My problem is that I want UIView1 to be transparent so that the information behind is still visible. All my attempts, such as
setting the bg color to transparent
changing the alpha value
removing the Opaque indicator
have failed so far.
Any clues? most appreciated!
UINavigationController is not designed to allow "buried" view controllers to still be showing under the current visible view controller. (The iOS framework can actually unload the views of view controllers on the nav stack that aren't the current top item!)
So if you try to do it, it just won't work, or you'll have problems. (Same goes for modal view controllers on the iPhone -- even if you make the background transparent, the view you're pushing on top of will disappear.)
If you really want the old UI to still be visible underneath, consider presenting your new entire UI as a UIView placed over the current view (i.e. do [existingView addSubview:myNewView]).

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.

Using translucent UINavigationBars

I am using InterfaceBuilder to set up my app. I have several views being controlled by a UINavigationController. In IB I set up the views using the simulated metrics to position the elements below the Navigation Bar.
I have a background texture that is placed in the window object of the Main.nib so that it is shared throughout the app. I want that texture to be visible behind a transucent navigation bar.
If the actual navigationBar's style is BlackOpaque the elements of the various views are positioned correctly below the navBar when the app is run.
If I set the NavigationBar to be translucent, view elements are repositioned to the bottom of the status bar when the app is run so that they are visible behind the navigationBar, even though they are positioned correctly in their various nib files.
How do I defeat this behavior?
I figured out the answer...
If you do NOT want objects to be slid up to be positioned behind a translucent NavigationBar, In IB, set the simulated metrics for the navBar to none, and position the view elements as desired.