macOS High Sierra和CAShapeLayers,NSImageView,NSTableView冲突 [英] macOS High Sierra and CAShapeLayers, NSImageView, NSTableView confilcts

查看:116
本文介绍了macOS High Sierra和CAShapeLayers,NSImageView,NSTableView冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已更新到macOS High Sierra,现在在我的项目中遇到了意外问题,这些问题在macOS Sierra之前从未出现过. 我具有自定义NSImageView,并且在此NSImageView中拖放图像后,可以使用CAShapeLayersmouseDownmouseDragged函数在图像顶部绘制矩形.然后,我可以计算矩形内部图像部分的强度.强度数据在数组中,该数组用于NSTableView. NSImageViewNSTableView在同一NSView中.强度计算在@IBAction函数中.更新后,当我按下用于计算强度的按钮时,矩形移到图像下方(在它们停留在顶部之前).我发现,造成这种影响的原因是表的reloadData()函数.关闭此功能后,矩形将停留在图像上方.

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.

更新 我已经更新了High Sierra,但是NSTableView的reloadData()与以前消失CAShapeLayers的效果相同.

Update I have updated High Sierra, but reloadData() for NSTableView has the same effect on disappearing the CAShapeLayers as before.

推荐答案

升级到High Sierra后,我遇到类似的问题,我添加到NSImageView的子视图不再显示.

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

这篇关于macOS High Sierra和CAShapeLayers,NSImageView,NSTableView冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆