Navigating Text box on a pdf is not working any more after iOS 13 - seems gestures issue using PDFKIT

前端 未结 1 1992
礼貌的吻别
礼貌的吻别 2021-01-24 00:22

I implemented a project I used PDFKIT to do some how adding a floating Textbox on a pdf and it can navigate by users touch on screen using GestureRecognizer to move

相关标签:
1条回答
  • 2021-01-24 00:44

    Its hard for me to understand what could be the problem by looking at your code. Here's my high level suggestion: 1. Make a backup of your code first to make sure you can come back to your stable state. 2. Start cutting the code in half - eliminating half of the logic path each time. For example: Instead of using a PDF view, use a regular view with a text box (to find out if the problem is with the PDF view). Instead of using a UITextField, use just a UIView to see if it's a problem with UITextField.

    Basically remove all the complexity gradually until you are left with a simple piece of code that allows you to move the text field.

    Also: avoid having such long methods. I try to keep methods down to 30 lines max, and 2 levels of nesting max. Otherwise you will have more logic paths than you can maintain or understand...

    You are also relying on strings for object types. This is fragile. Maybe there's another way to find the PDF View instead of crawling the whole view hierarchy for it, and checking strings? (They are not compiler checked, so any change in the future or change between OS / Third party versions will break your code).

    If your text field doesn't move at all, try to remove all that math you're doing with the frame, and just get it to move using gesture recognizer to any coordinate (for example: 200, 200), just to see that something is holding the text field in place (like a constraint). Do you have constraints that can be holding it? Use the "View Inspector" to check and verify how the view is embedded and what's above / below it. Is there anything that could be intercepting touches to your gesture recognizer? Is it receiving touches and firing it's event? You need to describe more exactly what the problem is... Please refer to my answer here for things to check on the Gesture recognizer itself. UIPanGestureRecognizer is not working in iOS 13

    Your view hierarchy is so complex with this PDF view that it's hard to say what could be happening with other Touch events inside it . (unless you understand exactly how the third party PDF View works). I would try to isolate the problem, whether it's related to the PDF view or not. Get it working in just a regular View first. Then work on the PDF view by using hitTest, and put a print statement there, to see who is competing for the HIT test.

    0 讨论(0)
提交回复
热议问题