问题
I have updated to macOS High Sierra and have now unexpected problems in my project, the problems not seen before in macOS Sierra.
I have custom NSImageView and after drag and drop of image in this NSImageView
I can draw the rectangles on top of the image using CAShapeLayers
and mouseDown
, mouseDragged
function. Then, I can calculate intensities of the image parts inside of the rectangles. The intensities data is in array and this array is used for NSTableView
. NSImageView
and NSTableView
are in the same NSView
. The intensities calculation is in the @IBAction
function. After the update when I pressed the button for calculation of the intensities the rectangles moved below the image (before they were staying on top). I have found out, that the reason for this effect is reloadData()
function for the table. When this function is turn off the rectangles are staying on top of the image.
Can somebody explain this strange things and what I can do to fix it ? I need to keep the rectangles on top of the image after I pressed the calculation button.
Update
I have updated High Sierra, but reloadData()
for NSTableView has the same effect on disappearing the CAShapeLayers
as before.
回答1:
I have a similar problem after upgrading to High Sierra, the subviews I was adding to my NSImageView were no longer displayed.
To solve the issue, I added the following line to my code (NSImageView was added programmatically), as recommended by this link:
imageView.wantsLayer = true
来源:https://stackoverflow.com/questions/46423303/macos-high-sierra-and-cashapelayers-nsimageview-nstableview-confilcts