You can add something like this to the code: (This is a little rude, so you may have to work out some errors)
if([gestureRecognizer view].frame.bounds.x < self.view.bounds.x - panExapantion) {
Edit: Okay, consider the box inside the drawers, so we have an inner box and an outer box. If we do not want the inner box to go outside the outer field, we must have all of these statements:
- The moved left side of the indoor unit is not outside the left side of the external box.
- Moving the right side of the indoor unit is not outside the right side of the outer box.
- The moved bottom side of the indoor unit is not outside the bottom side of the outer box.
- The moved top side of the indoor unit is not behind the top side of the outer box.
In your case, PDF is the inner box, and the iPad is the outer box. To stop the publication of PDF code outside the field, we need to check whether each of these statements is true, and if it is false, we do not move the PDF to a new location. Or we move the PDF document a little closer to the edge of the iPhone. screen.
The problem is that the pinch and scaling are used, and suddenly the box will always be outside the outer box, so how do we fix it? We get how many pixels were added to the inner box when it was enlarged (for the bag of this explanation, you can simply call this extension). Thus, we get how the box was expanded and subtracted this value. For example: (This is an if statement and does not work in code)
If(outerBox.leftSide is less than innerBox.leftSide - panExpantion) {
I was hoping this helped clarify!
source share