I have Rect and origin. I will check my origin point is in rect or not.
My Rect is:
aRect = (origin = (x = 0, y = 44), size = (width = 768, height = 306))
ptOrigin = (x = 201, y = 313)
if (!CGRectContainsPoint(aRect, ptOrigin) )
[self.scrollView scrollRectToVisible:aRectTextView animated:YES];
The logic is as follows: The point is inside iff:
ptOrigin.x > aRect.origin.x and
ptOrigin.y > aRect.origin.y and
ptOrigin.x < aRect.origin.x + aRect.size.width and
ptOrigin.y < aRect.origin.y + aRect.size.height.
In your case that results in
201 > 0 and
313 > 44 and
201 < 0 + 768 and
313 < 44 + 306
Since all 4 are true, the and-ing is true as well.