Can't adjust autoresizing mask for viewController - ios

I'm trying to adjust my app to iPhone 5, but I ran into some difficulties.
The header of the ContainerViewController (always stays on top)
The ContainerViewController that holds the other ViewControllers
SidebarViewController
ContentViewController
So, the container contains the header, sidebar and content views. Inside content view I have UINavigationController. My problem is when I use iPhone 5 it changes all of the application looks, even when I use Autoresizing Mask, it looks bad and not on the correct position, I think that it's maybe because of the container header that I created.
I set it like this:
And this is an example of the view that holds UIScrollView and UIImageView as background: (pay attention to the bottom of the UIScrollView and the UIImageView, it pushes them outside of the view.
iPhone 4:
iPhone 5:
This is the first time i'm using Autoresizing mask, so please be patient with me. Thanks in advance!

Am not going to answer this deep down. You have set the auto resizing wrong.
Here are things that will work. To deal with iPhone5 you just need UIViewAutoresizingFlexibleHeight as autoresizingMask
If you want to know properly about Auto-resizing read through this
For Container
For Header
For Content
For Side Bar

Related

Parent UIView in StackView displayed wrong, but its subviews are correct

I have a problem where the frame/layer is shown correctly on iPhone, but not on iPad and iPhone X. Only after going to another view and back to that UIViewController it is shown correctly.
I have a 3 UIViews in a vertical StackView. The first top 2 are shown correctly. But the third is not. The third UIView contains a containerView and in it there is a TableView. Through the view debugger I can see that the containerView and the tableView have the correct frame, but it looks like the parent UIView is not redrawn correctly.
Here is a screenshot of the view debugger from the front of that UIView. The UIView with the red background is the one displayed incorrect (correct after going away and back to that UIViewController).
UIView with red background incorrect (Frame is correct, but displayed wrong). The subviews have the correct frame. I set a backgroundcolor to those subviews and these are redrawn correctly
Here the same view from the back:
UIView in question from behind
I tried .setNeedsDisplay., .setNeedsLayout, followed by .setLayoutIfNeeded. Running those in main thread, but didn't got success so far.
I am using Swift 4 and iOS 11. As I said this is in a vertical StackView. The first 2 UIViews have a height constraint, this one, has no constraint as it should fill the rest.
Any help appreciated!
The problem was solved for iPad and iPhone X, removing the shadow layer on the view that was drawn incorrectly.

UIViewController subviews added in interface builder not showing up

Ok so basically I just used the interface builder with auto layout to add some subviews and constraints to my UIViewController. My app is supposed to segue to this view when the user wants to take a photo. I laid out a few camera buttons on a black, square UIView that will serve as the camera view once I have programmed it. Since I wanted to make the camera view a square, I also had some extra space where I just made a label that says "Take a photo!" This is how the interface builder for this view controller looks:
And this is how the same view looks when I run the app:
I'm guessing it's something simple that I'm missing that's causing this problem but I will be grateful to anyone who can help me!
When you are using autoLayout you should set all needed constraint to the view. Otherwise it is an ambiguous layout problem, and the system is not knowing where to set your view
If you want the height to be the same like the width set the aspect ratio constraint to your view
And be sure that the multiplier of constraint is 1
Bring that subview to front, putting all other views to its back
try it will work
parentView.bringSubview(toFront: childView)
This method can also be used to bring any subview to the front, even if you're not sure where it is:
childView.superview.bringSubview(toFront: childView)

AutoLayout Not Working For 5.5" iPhone

In my app, I have a screen that needs privacy, so when you first open it, it will check if you have logged in with the password. If not, it adds another view on top of the SuperView until that password is entered. I use XIB file for this. The main View of the screen is a tableview, and I drug on another UIView to use as the Password screen. However, despite AutoLayout, the Password view is only taking up the dimensions of 4.7" phone, meaning you can see behind it on the edges. I made sure AutoLayout is enabled, and on the background image, which is the gradient, I added 4 constraints, one for each side, set to 0, so that it would always cover the view behind it, and then set the UILabel to be aligned horizontally in container. What am I doing wrong? This works PERFECTLY in a different view and XIB within the same app, and I even copied the view straight over, but it is still messing up on this one class.
Code to load this is (password is the UIView declared in the header as IBOutlet UIView *password:
[self.navigationController.view addSubview:password];
The correct solution is to use a view controller to manage the curtain view, and either push that view controller onto the navigation controller's stack, or present it from the navigation controller or the tab bar controller.
There may be 2 possible reason
you may not applied constraint on your xib.
you have applied constraint on it but when you are initialising your xib you are providing fix frame.
it would better if your share your code how you are doing it ?

scale subviews to fit inside uiview

What I'm trying to do is very simple...i think. I want to make sure all the subviews within a view in my view controller are scaled to fit. Inside it.
My view controller has a menuview (subclass of uiview). Within that there are uiimage views, labels, and a button. The MenuView class I created has a nib file with a uiimage view that I want to scale to the size of the menuview depending on the device used. I'm not sure if the menuview is not staying constrained to the screen or if the uiiimage isn't, but when i run my program the menu runs off the screen.
Question:
- Can I force this (uiview and/or uiimageview) to stay on the screen using storyboard (programmatically is ok, but would prefer to try with storyboard)?
If anyone can point me to a good introduction to auto layout view and understanding the mainstoryboard that'd also be appreciate because it's insanely frustrating.
Screenshot: in the image below you can see I have a letter image that I want within the limits of the screen.

Using UIScrollview in iphone5 compatible app

I have a problem adapting my apps to the new iphone5 layout, I've made the following passes:
Added a retina 4" splash image
Modified the interface in my storyboard with "Size inspector" to change the anchoring of the widgets
Tested the app with iOS6 "retina 4" simulator.
The app works as expected except when the user pop up the keyboard to edit a text, I use the "stretching scrollview" method for this particular situation and this seems not compatibile with the "autosizing" properties of my widgets, here is an example, from iOS6 simulator, without and with keyboard:
And here is what happens:
I'm quite sure this is a coherent behaviour since my main view is stretched so the other items inside it are stretched following their anchoring, the fact is that I'd like to have the same behaviour of my previous fixed position (all widgets anchored to the top left corner) with the iphone5 gui expansion, is this possibile?
How do you solve the problem of showing a keyboard and scroll hidden content in an iphone 5 compatible way?
I have been having similar problems. From what I have found thus far, we may need to remove all constraints on the view within the scrollable view, because it appears that it's contents are being resized along with the frame of the scrollView. I know that setting the internal view's frame manually in viewWillAppear will work, but then you are stuck having a view that is the same size for both iPhone4 and iPhone5 (albeit it will scroll). Or you could "pin height and pin width" of the internalView right there in storyboard.
Two potential approaches that may work. Sorry I can't confirm these as I'm giving up and redesigning around this problem.
1. Programmatically add constraints to your internal view's subviews. The programmatic constraints will allow you to "spring" the distance between your elements proportionally. When adding constraints programmatically, you are given access to a factor called "multiplier" (not to be confused with priority), which I saw someone else on stackoverflow posting about.
2. You can design the internalView in Interface Builder as a separate viewController with it's .xib file, and then use storyboard to load it as an embedded viewController to a "containerView" object, which you would put in place as the new "internal view" of the scrollView. Perhaps then the .xib would first resize to the correct iOS device, and then you could use its frame to resize the containerView.
My advice is create a small test-case of these before implementing, else you end up like me, having spent hours down the wrong path and facing a dead-end.
UPDATE 12/4/12
Make your life easier by NOT setting the ScrollView as the main view of the ViewController.
--Instead, make ViewController.view a dummy/blank view, and embed a scrollView inside that view. Then, embed another view (my CustomView) in the ScrollView. CustomView contains all the visible controls and text boxes and buttons. There is NO HEIGHT CONSTRAINT on CustomView.

Resources