0
我想在iOS中做一些類似於UserInteractionEnabled = false的東西,但似乎這個屬性在NSView中不可用。我也看到,一種方法是實現hittest方法返回null,但這個lass的hittest已經有一個不平凡的實現,我不認爲我可以將它設置爲返回null。我發現一個名爲acceptingTouchEnabled(不推薦)的屬性,我想知道它是否可以實現與UserInteractionEnabled相同的功能。 該項目是在Xamarin完成,順便說一句。如何禁用nsview的userinteraction
FreeHandView = new PaintBoardControl
{
BackgroundColor = UIColor.Clear,
TranslatesAutoresizingMaskIntoConstraints = false,
UserInteractionEnabled = false
};
這是變量的原始聲明,其中UserInteractionEnabled設置爲false。
,這是則hitTest方法在我的Mac應用程序的執行情況:
public override NSView HitTest(CGPoint aPoint)
{
aPoint = ContentContainer.ConvertPointFromView(aPoint, this);
aPoint = new CGPoint(aPoint.X + _freehandViewLeftConstraint.Constant,
aPoint.Y + _freehandViewTopConstraint.Constant);
if (_hitTestBitArray != null && aPoint.X >= 0 && aPoint.Y >= 0 &&
_hitTestBitArrayWidth > aPoint.X && _hitTestBitArrayHeight > aPoint.Y)
{
var index = aPoint.Y * _hitTestBitArrayWidth + aPoint.X;
return _hitTestBitArray.Get((int)index) ? this : null;
}
return null;
}
感謝!我一定會嘗試一下 – Xiangyu