Cocoa Resizing Two Stacked Tables - macos

I have a view with two vertically stacked Table Views. When I resize the application window, the lower table view expands. This is because I didn't specify a height for it. It has a fixed distance to the bottom of the window and a fixed distance to the table view above it. If I attempt to remove the fixed height for the upper table view, the constraints editor complains. Is it possible to have both table view expand equally when I resize the application? If not, is the possible to allow the upper table view to be resized when the application is running?

I found a way to do this as long as there is some sort of control between the two tables. A label will work fine. Using constaints:
For the control in between the two tables, set the Alignment constraint to "Vertically in Container. This will perfectly center the control. You can offset it above or below center by adding a positive or negative value in the combobox next to the option.
For the top table, pin the top of the box to the top of the window or any other place that fits your design.
Set the bottom constraint to some offset from the control in step 1.
Set the bottom constraint of the bottom table to something fixed like the bottom of the window.
Set the top constraint to some offset from the control in step 1.
Be sure not to set the height of either table.
When the window moves vertically, the control in step 1 will be moved to keep it in the center plus or minus any offset you provided. The two tables will be expanded or contracted accordingly.

Related

Xcode 8 - How To Disable Auto Adjustment Of Views When Deleting a Constraint In Storyboard

Before when I delete a constraint that sits between two views, the position or size of the two views doesn't get affected(meaning they don't automatically adjust itself in the storyboard). But now it does. An example would be let's we have two UIButtons aligned horizontally. I set the height and width of one equal to the other. Then if I delete one button, the other button will change it's size in the interface builder.
Is there a way to disable the auto adjusting of sizes and position of views when their constraint changes?

VB / C#: Resizing two controls equally

I have made a window in which I will be having two groups/panels and some buttons in between them. I want to code the resizing behavior in a way that when the window expands, the two panels increase their widths while keeping the distance between them constant.
Please see this mockup:
As you see above, I want the 'Local' and 'Server' Panels to resize while keeping the distance in between them same. If I use anchors (Top+Left+Right+Bottom), the left panel will overlap the right one and the right's width one will go out of the window. I want them to share the increased width of the window equally.
As for the buttons in between, I have kept ancors as Top only. By removing Left anchor from button, it automatically places itself in the center of the window when window is expanded, which is just the way I want it to be.
Any ideas how to manage resizing of panels?
Thanks.
Use the TableLayoutPanel control.
First add the TableLayout to the Form and set its Dock() property to Fill.
Next you'll need to setup 3 columns and two rows. Add the two buttons to the middle column with each one is in its own row. Afterwards, setup the column values so they are like this:
Leave the rows at 50% on both.
Now add your two GroupBoxes to the 1st and 3rd columns in the 1st row.
For both GroupBoxes, set Dock() to Fill, and RowSpan() to 2.
For the top Button, turn on only the Bottom Anchor.
For the bottom Button, turn only the Top Anchor.
For the TableLayoutPanel, set Padding() to 5,5,5,5.
Here is what it looked like when I was all done:
Resize the window and observe how the controls behave...

Trying to understand Auto Layout

I'm trying to understand how to use Auto Layout but I haven't been able to wrap my head around how to accomplish something like this using it. I have an iPad ViewController with two subview views. I'd like the layout to work like in this representation but I'm not clear on which values to set. particularly the relationship between the two subviews:
The left view should be pinned to the superview's top, left and bottom edges (with your padding) It's right edge should be pinned to the right view's left edge.
The right view should be pinned to the superview's top, right and bottom edges (with your padding). It should have a width constraint with a constant value, which you would set to the appropriate number on rotation.
In IB, you'd create an outlet to the width constraint. In code, just assign it to a property as you create it.

cocoa: weird purple constraint for split view

If I add three split views as following image, the third split view, referred as splitView-3, will automatically generate a constraint for custom view in that split view, like Height(42) of customview1. As a result, I can't change the height of customview1 in Interface Builder.
why does Interface Builder automatically generate a purple constraint, like Height(43), for customview1?
Any help would be appreciated.
It generates it because you manually sized the view to a specific height in its superview. Promote the constraint (in the size Utility Panel) to a user constraint and delete it. That should get you most if not all the way there (but I can't tell without seeing the rest of your constraint configuration).
Joshua is right... but there is one little tidbit I think needs to be explained.
Xcode needs constraints to determine position and size of ALL items. The purple ones it sticks in because there aren't enough constraints to satisfy those needs without sticking in a few extra.
So, Xcode is sticking in a constraint for height, that means it has no way to determine the height from your existing constraints. You can define it by adding constraint so:
the height is equal to the height of some other item
by setting the bottom distance X points away from another item
by setting the bottom position relative to it's superview
or .... well, a lot more, but hopefully you get the idea
Once you add in a constraint which let's Xcode know the view's height, that purple one will either vanish or become blue so you can delete it and have it not come back.

How can I blend in my SegmentedControl in a UITableView better?

As you can see on the screenshot the segmented control is placed rather ugly this way.
I need it in that place, meaning below the section title and before the second cell for that section. How could I make this better?
I can think of two suggestions that would improve the appearance. The first would be to increase the height of the table cell (just that particular table cell, not all of the cells in your table) so that the whitespace margin at the top and bottom of your segmented control is equal to the margin you currently have on the left and right of the control.
Another solution would be to move the selection of the value for this setting into a separate tableView controller that you drill down to. So that cell would show the current value, but tapping the cell would take the user to a new view where the user could select to change the value.
Here is an example of this from the Instapaper app settings page that I think looks pretty clean.

Resources