Remove padding on NSTableView / Big Sur with style = .fullWidth

Big Sur added a new property *style*, that defaults to automatic. Even though I'm setting it to full width, I can still see a difference between my app running on Xcode 12.1 vs 12.2  

When debugging the interface I can see that the edges contain the table row. Which means that the cell is not occupying the entire full width of the row. 

Please let me know if there is a way to get a single cell view to expand the entire tableview width.


Accepted Reply

Just to confirm the .plain style has the same issue as the full width style.

Replies

.plain
Can you explain this in more detail? Big Sur adds a few new defaults that are likely to break apps or make them look horribly ugly. This table style is one of them. I haven't noticed any difference between 12.1 and 12.2. It kind of sounds like you have some auto layout problem instead. Those can be tricky to debug, especially in TableView, and especially on Big Sur. It is easier to develop on Catalina and then use Big Sur only for testing. You have to hack your way around some of those new default settings though. It can be ugly.
Thank @Etresoft!, I would have liked to add some pics to the post, but as we can't do that, I will try to explain more carefully.
I created a really simple application that uses the fullwidth style with 1 column with a table view cell that only draws its background. When debugging the view with the Xcode hierarchical debug button, I can see that the cell is not occupying the entire tableview row view. There is still some padding horizontally on both sides. When I debug using 12.1, the cell occupies all the row correctly.
I will try the .plain style as @galad87 says but I think I already tried it without any luck.

I have a question on an external website with pictures attached named: How to remove NSTableView indentation on Big Sur that includes the example app and the screenshots.

Thanks again !

Just to confirm the .plain style has the same issue as the full width style.
OK. I think I figured it out. Table view cells have some hard-coded padding you can't avoid. I don't think that is necessarily a bad thing. I've never noticed this. I think it would only be a problem if you had some large image that you wanted to bleed right to the edge. You might be able to fix it by manually hacking the frame of the cell. Table views, at least on the Mac, are just really tricky this way. I think an iOS table view could probably go right to the edge with no problem. Maybe look for some Apple demos. They tend to all do the same thing with a sidebar of images that go right to the edge.

In your example, I was able to hack it to get it to the edge. I turned off content insets for the clip view and manually set them to negative values. Even then I could only hack the left inset. The right one is for the scroll bar and that is automatically adjusted.

This would really only be an issue if you wanted a table view that consisted entirely of full-width images.

In my app, I do something similar to what you are doing with the background. The trick is, I'm using a custom row view, like this:

Code Block
- (NSTableRowView *) tableView: (NSTableView *) tableView
  rowViewForRow: (NSInteger) row

This view does go to the edge.


Thank you @Etresoft for checking the example !
When you say you return a custom row, you are populating your own custom row and not returning anything on the viewForTableColumn data source call ?
Thanks.

When you say you return a custom row, you are populating your own custom row and not returning anything on the viewForTableColumn data source call ? 

No, everything is using default settings otherwise. My view is used in conjunction with a web view, but the web view screws around with focus. The only thing I am doing in my row view is setting the active status by overriding the "isEmphasized" method.


I make a mistake and set as answered my reply. The Correct answer is .plain but with a few caveats:

 I tried the plain style as suggested but it looked exactly the same as the fullwidth. I also tried setting self.tableView.intercellSpacing = CGSizeMake(0, 0) but also it didn't work.

But finally this is what worked:
Set the style to automatic in interface builder
Set the style to plain in view did load.
I tried other combinations like 1.plain and 2.plain and it didn't work.