WatchKit Interface : Is it possible to add multiple labels in a tableView group without any of the labels being pushed to the right? - objective-c

This is somewhat hard to explain, but basically I have one label in a tableView group that needs to take up the width of the group and placed at the top. I want to add a second label at the bottom of the group and take up the width of the group as well. However, I cannot do this. When I add my second label it gets pushed to the right automatically. Seems, the second label can't be on the same horizontal plane as the first label. Is there a way to resolve this. I can place my second label at the bottom, but it just gets pushed off to the right and off screen.

Add both labels to the group and then, set in that group vertical Layout (Attached screenshot). Also both labels should have width: relative to container

If you look at the group's settings in Interface Builder, you'll see an option to change the layout type to Vertical, rather than the default Horizontal. That should help you achieve the layout you're looking for, if I understand correctly.

Related

How do I make constraints to UITableView with multiple cells with static and dynamic height?

I searched a lot about this, couldn't find an answer and I am stuck with this problem for some days already.
I have a UITableView with 3 sections, each one with custom cells (xib). The first section must grow accordingly with one of its labels.
The second one is static, it shows up just an static image and basic height.
The third one is like a comment cell, with UIImageView, labels etc. One of this labels must grow till a limit height.
I managed to show the 3 custom cells, but the first and the second one (which are not static height), show only partially. If I set manually the Height of the row I can see it entirely, but all section cells grow and it is not what I need.
The constraints to auto layout, I keep getting some conflicts but could not find any solution, tried to debug the view stack, no success.
Custom Cell
Constraints of custom cell
Can anyone help me or point me to a direction?
Thanks in advance!
I had the same problem. I solved it like this. Set tableView estimatedRowHeight to minimum row height. Set tableView rowHeight to UITableViewAutomaticDimension.
1) For dynamic cell height - Give the label leading, trailing, top, bottom and height greater than equals to minimum height.
2) For fixed cell height - Give the label leading, trailing, top, bottom and height equals to fixed height whatever you wanted.
By this your dynamic height cells will grow and fixed ones will be fixed. If you did not get what i said then post a sample project with just this custom implementation on git or somewhere else. I will correct it.
Thank you.

NSTableView section banner column with custom height

I am trying to create the following layout with a NSTableView:
A big banner per section on the side and regular text content rows on the right side.
The Image on the left side is the problem. It should behave like a floating section when scrolling (stay below the section header). It seems impossible to have the view part of the NSTableView as each column of a row needs to have the same height.
I already tried a lot of things, but I need some input which is the right direction.
What I tried:
Add the image view as a floating view into the NSScrollView? That seems like a good approach, but it doesn't stick on top while scrolling and the (re)positioning within the table is... tricky. Any hints here?
Add the view into the section header and disable clipping somehow (to make them larger than the section)? Couldn't make that work.
Having a table with NSStackViews per row that host itself tables - that did work, but: Independent selections per table is not what I want.
Ok, I finally found a solution.
The view is added to the floating view container of the NSScrollView that holds the NSTableView. I use the bounds of the row views and translate that to coordinates of the floating view container.
I also modified the selection drawing to make it look good and recalculate the coordinates on animations.

Autosizing vertical line in Obj-C on OSX

I have this window :
And when I resize it, it becomes like this :
In XCode Builder, I have this config for the vertical line :
My question is : How can I autosize the vertical line so that it moves along the tableview.
(The right empty space has a custom view. It's not really empty.)
EDIT
Here is the table view autosizing
In autoresizing masks system, it is not possible to have the line to stay at fixed distance from right edge of the table view during resize, unless the table view right edge is also pinned to container's right edge. So you need to place both table and the line into another view (Custom View) and configure flags like this:
Table View: |====| <====> |=====|
Vertical Line: ---- ---- |=====|
The best you can achieve without an extra container is to disable all horizontal flags for the line, but then the distance between it and the table will variate as the window resizes.
Alternatively, consider using AutoLayout, this is just one of many reasons it was created.
The problem appears to be that the table view's springs are wrong. The line itself appears to be moving fine, based on the screenshot.

dynamically load UICollectionView in xcode

We have a label followed by a UIViewCollection. The height of the label is dynamically set based on its content. Based on the height of the label, we want to start the UIViewCollection as soon as the label ends. We are tracking the label x, y, width and height and adding some padding to y in the code to calculate the start of UIViewCollection. However, UIViewCollection does not move at all. Is it because of the specified storyboard? We tried it in ViewDidLoad and ViewWillAppear.
Also, if we replace the UIViewCollection with a label such that there are 2 labels one below another, we are able to dynamically load the start of the 2nd label if the code is placed in ViewWillAppear.
Please can someone help with moving the UIViewCollection up or down based on the previous label height?
Thanks in advance.
It may be because You use autolayout. You can switch off autolayout or set translatesAutoresizingMaskIntoConstraints YES for UIViewCollection, and than set current location
If you're using auto layout this is easy to do, and you don't need to do anything in code to keep track of the label's height. The label should have a height constraint to the top of the view and a spacing constraint to the top of the collection view (the length of that constraint will give you whatever padding you want between them). The collection view then needs a constraint to the bottom of the view. This setup will cause the collection view to get shorter when the label gets taller. If instead, you want the height of the collection view to stay the same, but move down (assuming that it's short enough that there's room to move down), give the collection view a fixed height constraint, and remove its constraint to the bottom of the view.

Positioning UI controls without relying on centers

I'm creating a sample login screen to practice Auto Layout. In portrait mode, it looks like this.
However when I rotate to landspace mode, it looks like this.
Below are the constraints I have set in this layout.
I understand why this is happening. It is because I have a constraint for the User ID UILabel [ Vertical Space(196) ]. How can I position the UIlabel+UITextField set slightly below the horizontal center line of the screen when turned to Landscape?
I assume I can set maybe the middle label to Horizontal Center in Container and then have the other 2 labels positioned relative to that one. But what I'm looking for is a way to position them without the help of center positioning in container. I want them to position slightly below the horizontal center line. How can I do that?
Thank you.
I don't think there's any way to do that in IB, without using the center property -- you could make your views appear below the center by putting another label above User ID, but with no text in it, so it will be invisible. Center that one, and have all the others positioned relative to it.
select all controls and select Top space to superview
Now select only textfields and select Widths Equally
This should work. If not, then let me know i will send you sample code or screens of constraints.