Disable floating of header in NSTabelView? - objective-c

I am using view based NStableview and I am using table header for providing space between top of scroll view and first row of my TableView. I want this space to scroll up when user scrolls tableview, but the header is floating and is not scrolling up. It just sticks there on the top.
I need to provide a gap between top of scroll view and first cell of header view. I can think of other solution like creating a different cell for first row, but this solution creates whole bunch of bugs with indexes of table and data. So I decided to use table header for providing the space between top of scroll view and first row of table view.
Is there any solution for this other than using header for table? If no can I disable the floating behaviour of header view?

To disable floating just set floatsGroupRows = NO ?!

Maybe the contentInsets property of NSScrollView is what you look for.
You can define a top inset. (100 in my example)
Code (same for Swift and Objective-C):
self.scrollView.contentInsets = NSEdgeInsetsMake(100, 0, 0, 0);

Related

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.

Remove the Floating of headers in NSTableview

I have a NSTableview in my application. Theres a header and under these are some elements like rows of a table view. So when i scroll this table view the header stays put and it scrolls up only if the last element in the table view scrolls up and disappers. I Need the header to scroll like the remaining rows. Please help. Is it possible.?
Uncheck Floats Group Rowsin Attribute Inspector of the Table View

How to use Auto-Layout properly in this case?

I have a UIView and a UITableView. I'm trying to align them in a way so they are sticked to each other. The UIView has a fixed height and I want the UITableView to consume the rest of the horizontal space.
I applied a set of constraints which got me pretty close to what I want to achieve but there's a problem that I don't know how to solve. The layout is OK in the portrait orientation but there's a gap between the two elements in the landscape mode. Please see the screenshots below.
Here are the constraint setups for the elements.
UITableView: (all constants are set to 0)
UIView: (all constants are set to 0 except for Height)
Thanks in advance.
I had the same issue of that space appearing above the top cell of a UITableView.
Like yourself, I looked into the constraints and the properties of the table, though the only way I could fix the issue was to delete the UITableView altogether and re-insert it.
Once re-inserted the gap was gone.

NSTableView without scrolling, instead push down content below

I would like to create a NSTableView so that when it grows it will not scroll but instead push down the content below. The NSTableView and the content below will be wrapped in a NSScrollView that will autoresize with the windows height.
Is this even possible? I've spent a lot of time searching for any answer or even a clue on how to approach a design like this, but no luck. Should I even use a NSTableView for this?
See this image if you don't understand what I mean:
I think that you just need to calculate the total height of your all table cells and that value set as a table height. After that set your scroll view content size as a CGSizeMake(scrolviewwidth, table_height)
Select tableView and in attributes inspector in section Scroll View uncheck Scrolling Enabled. It is possible, that you will have to set table height manually viz previous answer.

Expand UITableView to full size?

I have a UIViewController. Within it is a UIScrollView with several views inside it. At the bottom is a UITableView.
This UITableView is dynamic and will display either a small number or large number of rows. Either way, I want the UITableView to be displayed full size so the user can scroll down to the bottom of it using the parent UIScrollView, NOT the UIScrollView inside the UITableView.
I've attempted this by disabling scrolling for the UITableView (this works fine). I've then tried at runtime to expand the UITableView so that all rows can be displayed correctly.
However, this part isn't working. For some reason despite the UITableView being really big, not all the rows are being displayed.
I've expanded the UITableView like this:
CGRect frame = tableView.frame;
frame.size.height = 5000;
tableView.frame = frame;
What have I missed? Is there another view inside the UITableView which I need to expand for all the rows to be displayed?
Sorry if this was a silly question, I've only been using iOS for the last month.
Thanks in advance for any help :)
To clarify, this is a screenshot of the problem.
The red area is the UITableView, so it's definitely the correct size. However, there are supposed to be 10 table rows. There are only 5, even less if I increase the size of the table rows.
What do I need to do to display all the rows? What do I need to resize?
While I see you've managed to get it running, placing a UITableView within your own UIScrollView may mean the table view can't manage its content cells as efficiently as it can when it handles its own scrolling.
But, how can you add your own custom views and have them scroll with the table cells? By making them subviews of the UITableView. If you add one or two subviews to a UITableView, it positions them above and/or below its content, and scrolls them with its own cells.
The screenshot below shows how this looks in the XCode interface editor. Note that the root view is the UITableView, it contains two subviews for the header and footer, and those subviews can contain whatever subviews you need.
I managed to get it to work fine. However, I have no idea what the problem was in the first place.
I moved the UITableView higher up so it was covering the other views on the page. It displayed fine. I then moved it down to determine what was causing the problems, and it started displaying perfectly.
I'll put it down to an error in where I placed the UITableView, as I can't see any other issues.