In my story board I have added a new custom view controller. It is 'connected' to the RootView Controller via a push segue.
This is the new custom UIViewController as seen in the storyboard
When I run my app in the simulator, I can see a border around the frame. (Of course it is visible because I set a background color to RootViewController)
I want to understand:
1) Why my custom view controller does not occupy the whole frame?
2) what is the orange color dotted line? Is it related to the question 1? What is the best practice (i.e. is the border a new behaviour and is not indicative of bad design etc)?
The orange dotted line shows that the view will change when the constraints are resolved, and shows where the view will end up.
If the view is correct in Interface Builder, just go to the Resolve Auto Layout Issues popup menu and select Update Constraints. That will update the constraint values to match the layout in Interface Builder.
If you select Update Frames instead, that will make the view match the constraints (causing the view to shrink to the orange dotted line in this case).
Related
I have created ViewController which has 0-0-0-0 constrains from superview.
And I recently got a task make this ViewController like a popup as shown in picture.
As you can see this white background which is my ViewController has some margins from left-right-top-bottom and shows some part of other ViewController.
How do I create this view in a quick way?
If you have given constraints in storyboard and not by programmatically, Then at the time giving constraints if the set to margin checkbox is checked, then possibly you have this space, which default margin to the screen.. :)
I've created 4 subviews of white color & a yellow one as you can see in reference image I've shared below.
And I've programmatically changed the position of Tabbar from bottom to top just below to navigation bar as you can see in below image (When it is running in the simulator).
Now since I've constraints for that yellow view in image as follow
It is appearing just below to navigation bar but I want it to be displayed just below the Tabbar.
Since Tabbar is getting its position programmatically & other views (including yellow view) are getting their positions from the storyboard.
And since storyboard UIelements are get settled before any other UIelement which are coming from the program or at least get their position from programmatically.
What could be the best way to achieve what I want.
Please refer my storyboard as well to get more understanding. (Refer Below image)
I also want to fit all 5 subviews in the space between tabbar & bottom of the screen. I want to calculate 1/5th of that space & assign this height to each subview. I'd later reduce few pixels to separate them.
Why not add the height of the tab bar to the yellow view's top position? That way, you'd set the constraint something like:
Fajar.top = top + 44
If the tab bar is always visible, then that should work. But of course, if the tab bar only appears at times, you'd probably have to change that constraint programmatically depending on the change ...
I have a modal view that I'm presenting over the current view that has a UINavigationBar as a subview. Everything's working great, except that the UINavigationBar doesn't want to behave according to the autolayout constraints. Everything else in the view behaves as desired.
For some reason, the left and right bar button items are cut off on the edges of the view. I inspected the view at runtime to reveal that the total width of the UINavigationBar is the right width, but the bar buttons aren't conforming.
I also checked to make sure I didn't have negative margins or some other anomaly in the constraint definitions.
I have also tried setting the frame of the UINavigationBar manually, but it yielded no improvement.
Problematic View
Constraints
I'd like to keep the UINavigationBar, because it gets styled globally with the rest of my app (as opposed to creating a custom UIView imitation and styling it individually). Does anyone know what handle to jiggle to get the bar button items to conform to the right width?
I know that there is 2 approaches when dealing with autolayout and hidden views:
Remove hidden view from hierarchy and add it back when needed
Change UIViews constraints to ignore hidden view
I have some complex case (imo). Here is my layout
Gray view is container view in my hierarchy on the left.
I have 3 blocks: green, yellow and red. Red and yellow also have titles (see small rects of the same color).
So the problem is that yellow and red could be empty. Adding view back would have rather difficult code (for example adding red):
I have to check if yellow block is here
I have to set lots of constraints in code. I could easily break my UI by changing constraints on Storyboard and not change it in code.
I need to hide red/yellow views when there is no info and show them again when there is some info (without reloading whole controller)
Are there any solutions without that problems?
I am trying display a UITableView within a larger UIView in an iPad app, mainly because the data is pretty sparse and I'd like to have the table be a smaller area over a background image, rather than taking up the whole screen. The parent UIViewController is correctly set as the table data source and delegate, and the table looks/functions like it should. The whole view is embedded in a navigation controller; the overall UIView shows a navigation bar, as it should, that I can configure normally.
The problem is the UITableView subview also shows blank space at the top for a navigation bar--empty space above the first cell--and I can't figure out how to get rid of it. I know the space is related to the navigation controller, because when I delete the embed link in the storyboard, the space goes away. The table view doesn't present a UINavigationBar property or any other navigation-related properties that I can try to nullify.
I would post a screen shot but I don't have the rep yet.
Can anyone explain where the space is coming from and how to nix it?
I suspect the answer is related to the Top Layout Guide for the view, but I can't diagnose the specific problem.
Here's a workaround from the storyboard: Insert a UIView in the scene, then drag the UITableView into it as a subview. Check the box for the new UIView's "Clip Subviews" in the attribute window, and then use it as a mask, basically, to cover the undesired top margin of the table view. It works and doesn't require any coding, but there has to be a better way.