Prevent NSTableView / NSOutlineView from separating cells - objective-c

I have a Mac app with a view-based NSOutlineView. The outline view seems to separate its rows so the background color of the nearest ancestor view with a background shows through. How do I prevent this? I've already set grid style to none.

I figured it out. There's a method called setInterCellSpacing on NSTableView that separates the cells. Mine was set to non-zero values. Set it to NSZeroSize and the issue goes away.

Related

Background color in cells in NSTableView is 1 pixel off

I am making an OSX app, and for part of it, I am using NSTableView to simulate a "timeline", by putting in a really thin column and then setting the background color. It's fine, except for whatever reason the cell seems to be 1 pixel off whenever the background color changes. Anyone got any ideas? I don't have the reputation to post an image so here's the link: http://imgur.com/PrLdjIV
Thanks for reading this!
An NSTableCellView will not necessarily fill a row from edge to edge. Likewise, an NSTextField inside such a cell view will not necessarily fill it from edge to edge.
Implement -tableView:didAddRowView:forRow: in your table view delegate and set the row view's backgroundColor.

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.

UICollectionView does not reveal all cells in Simulator

I am not very experienced with UICollectionView and Auto-Layout.
I have a very basic UICollectionView inside a root view. The root view seems to have a Navigation Item.
I created a custom cell which is really a square in proper size to allow 2 such cells per row using the FlowLayout.
There are 8 such cells in the view - it is basically a grid. I have absolutely no constraints on the view.
The collection view occupies the entire size of the root view according to the IB and in the editor, the first cell is placed right under the navigation item which is perfect.
However, when I ran the app in the simulator and scrolled the collectionview all the way to the button, I see only a partial fragment of both cells in the last row. I can see I have scrolled all the way down...
Obviously there seems to be some sort of overflow...but I would have thought uicollectionview would automatically handle the overflow and make all the cells visible?
When I set number of items in IB I can see that the cells in the last row are only partially visible.
Seems like content size of the collection view is not right - that's my guess..
What do I need to do to adjust things in IB so that all of my cells are visible...I do not want to hardcode any values in the code...
Thanks.
Solved. It turns out simulator does not show the entire collection view...the same shows fine on the device... What a headache...

Animating cells while UITableView is scrolling

I'm trying to achieve an effect wherein as a tableview is scrolling, the currently visible cells will animate according to where they are positioned on the screen. I'm somewhat new to IOS dev, so let me try to break it down:
Tableview loads with custom cells User begins scrolling While the
table is in motion, the visible cells have a UIView in which I would
like to perform an animation that corresponds directly to the cell's
current Y position on the screen.
Cells will ONLY animate when they
are visible
Cell animation directly corresponds to table motion, i.e.
whenever the table view scrolls, the cells are animating; once the
table stops, the animations pause
One solution I have thought of is to update drawRect every single frame when the tableview is moving. Depending on the graphic operations, this could be horrible performance wise. Is there a way to grab the current table position every time it changes? Would I be better suited to use Core Animation?
This might be helpful if you want to achieve something like below:
https://github.com/mrugrajsinh/AnimatedTableViewCellDemo
Make your view controllers the delegate of the UITableView, and use all the methods of scrollview Delegate also. There you have many controls for start scrolling and end scrolling, and within thpse controls you could check for uitableview cell positioning.
You have to become delegate to this: https://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITableViewDelegate_Protocol/Reference/Reference.html
and this is the method to override and animate your cells:
– tableView:willDisplayCell:forRowAtIndexPath:

custom NSTableCellView in NSTableView, sometimes cell blank, maybe related with scroll and resize

I have a NSTableView which is a list of a custom NSTableCellView (only one column). The problem is, after resize and/or scroll and/or some NSPredicate filtering, some rows are not shown, only a blank cell in the row, but there is a NSImage picture is shown correctly, ALWAYS, wonder if this has something related with NSTableCellView.imageView.
I think this has something with the scroll/cache settings inside NSTableView, but I just don't have experience on Cocoa guessing where to begin. The table view is cocoa bound with NSArrayController, which uses core data for storage. Thanks a lot for helping :)
This is very strange behaviour, but something that I have observed.
I was using hi-res artwork (300x300px images) and allowing the NSTableCellView to scale the image down. When I supplied the table cell view with 20x20px images the text was never missing.