mardi 20 mars 2018

Why do I need wantsLayer for Check Boxes in a Table View in macos

I have a simple cocoa app for macos, the whole UI is created programmatically i.e. I'm not using the interface builder (no xib-s, no storyboards). I'm creating a scroll view, adding a table view with a single column and feeding it with cell views containing check boxes.

So the view structure looks like this:

window

root content view

scroll view

clip view (created automatically by the scroll view)

table view

cells view

check box

The problem is that the check box is behaving weirdly in this structure - it doesn't repaint itself when clicked. BUT - if you click it and then resize the window (I have auto-layout constraints there, too), then the table view is redrawn and the check box is redrawn too and thus updated.

I've been trying various things to localize the problem (I'm new to macos, therefore I tried pretty much everything) and found out that if I turn the wantsLayer on for the cell view or the check box itself, then check boxes start working properly.

If I don't wrap the table view into the scroll view, then everything works without wantsLayer, too. When I create check boxes out of the table view - just put them on the root view itself, they also work properly.

Please explain me why do I need the wantsLayer. Or maybe I need something else in reality and wantsLayer works just by accident?




Aucun commentaire:

Enregistrer un commentaire