Is there any way to detect if any point in a given rect is contained inside of another, larger, rect? I'm trying to figure out when certain rects are on the screen (for memory management to deallocate the ones that aren't) but the rects are large and so sometimes only parts of them will be on the screen but I still need to have them loaded into memory.
+1
A:
You can use -pointInside:withEvent:
which is a method for UIViews
.
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
Returns a Boolean value indicating whether the receiver contains the specified point.
See Apple's documentation here.
Brock Woolf
2010-08-11 07:07:18
But he is looking for intersection between two rects. Using pointInside, he'll have to check if every point in one rect is a pointInside the other rect.
lukya
2010-08-11 07:14:25
@lukya: Oops misread the question
Brock Woolf
2010-08-11 07:44:48
+3
A:
Use:
CGRectIntersectsRect(CGRect rect1, CGRect rect2)
you can use your rect's and the view's frame as the two parameters.
lukya
2010-08-11 07:10:09