A preliminary way to use the UIView convertRect method to detect CGRectIntersectsRect multiple times

I recently asked about collision detection in subzones with an excellent answer. I came up with the last issue about implementing collisions in my application, but I ran into a new problem.

Using convertRect was a good getting CGRect from subView. I needed it to be a little more complicated, as these were not exactly the rectangles that needed to be detected.

on Xcode, I created an abstract class called TileViewController. Among other properties, it has an IBOutlet UIView * detectionView; Now I have several classes that inherit from TileViewController, and each class has several views nested in the discovery that I created using Interface Builder.

The idea is that the object can be of a certain shape or size, I programmatically placed these "tiled" detection points in the center of the center of each object. The user can select an item and interact with it, in which case move it.

Now this method works to some extent, but I don’t think it works correctly with nested values, since detection is disabled.

A simplified version of this method works - using CGRectIntersectsRect on the detection itself, so I wonder if I am viewing and viewing views correctly?

I was not sure if it was being compared in the same view, but I suspect that I changed the code a bit at some point, instead of comparing the values ​​in self.view. I took viewController.detectView UIViews in interactiveView.detectView, but the result was the same.

It is falsified, so the subview changes color, but they change color when they don’t even touch each other, and when they touch the wrong representation of the UI, the color changes

+3
source share
1 answer

convertRect.

, (, ), . convertRect: toView: , ,

interactRect = [detectInteractView convertRect:[detectInteractView frame] toView:parentView];

.. , , UIView, , , , !

+1

Source: https://habr.com/ru/post/1739053/


All Articles