简体   繁体   English

缩放和平移iOS中UIScrollview顶部的CATiledLayer中绘制的pdf后,校正触摸位置

[英]Correct touch location after zooming and panning a pdf drawn in CATiledLayer on top of the UIScrollview in iOS

I am working on Atlas App in which I am displaying map which I can zoom and pan using pdf file. 我正在使用Atlas App,其中显示的地图可以使用pdf文件进行缩放和平移。 I am using vfr reader for this purpose and it is working fine. 我正在为此目的使用vfr阅读器 ,并且工作正常。 I want to detect the touch location so that I can get the correct state selected. 我想检测触摸位置,以便可以选择正确的状态。 I am getting the correct coordinate when view is not zoomed and panned using the code below: 当使用以下代码不缩放和平移视图时,我得到正确的坐标:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject]; 

    CGPoint point = [touch locationInView:theScrollView];
}

But,when I zoom it out and pan it,the touch location changes and I am not getting the correct state selected. 但是,当我缩小和平移它时,触摸位置发生了变化,并且我没有获得正确的选择状态。 How will I get the correct selected state? 如何获得正确的选定状态?

On debugging vfr reader classes I found that I can get the correct exact location of touch in ReaderContentPage class. 在调试vfr阅读器类时,我发现可以在ReaderContentPage类中获得正确的触摸的正确位置。 This class gives the correct touch location after zooming also. 缩放后,此类也提供正确的触摸位置。 You can get the point in processingSingleTap method as below: 您可以在processingSingleTap方法中获得要点,如下所示:

- (id)processSingleTap:(UITapGestureRecognizer *)recognizer
{
    CGPoint point = [recognizer locationInView:self];
}

CGPoint point gives the correct touch location. CGPoint点可提供正确的触摸位置。 And then use the delegate method to get the correct coordinates in the required class. 然后使用委托方法在所需的类中获取正确的坐标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM