1
CATiledLayer에서 터치 이벤트를 캡처하는 방법은 무엇입니까?CATiledLayer, CALayerDellegate 및 터치 이벤트 캡처
필자는 뷰 계층을 CATiledLayer로 변경하면보기가 TouchesXXX 이벤트 캡처를 중지하는 다음과 같은 상황이 발생합니다. 왜 이런 일이 발생하며이 문제를 어떻게 해결해야합니까?
public partial class DocumentView : UIView
{
public DocumentView()
{
//if the following lines are removed touch events are captured
//otherwise they are not
var tiledLayer = Layer as CATiledLayer;
tiledLayer.Delegate = new TiledLayerDelegate (this);
}
public override void TouchesBegan (NSSet touches, UIEvent evt)
{
//does not get called if we hook TiledLayerDelegate up there in the construct
base.TouchesBegan (touches, evt);
}
}
public class TiledLayerDelegate : CALayerDelegate
{
public DocumentView DocumentView;
public TiledLayerDelegate (DocumentView documentView)
{
DocumentView = documentView;
}
public override void DrawLayer (CALayer layer, CGContext context)
{
//draw happens here
}
}