check if UIView is in UIScrollView visible state

ios, ipad, iphone, objective-c

Solution

If you're trying to work out if a view has been scrolled on screen, try this:

    CGRect thePosition =  myView.frame;
    CGRect container = CGRectMake(scrollView.contentOffset.x, scrollView.contentOffset.y, scrollView.frame.size.width, scrollView.frame.size.height);
    if(CGRectIntersectsRect(thePosition, container))
    {
        // This view has been scrolled on screen
    }

Problem

What is the easiest and most elegant way to check if a UIView is visible on the current UIScrollView's contentView? There are two ways to do this, one is involving the contentOffset.y position of the UIScrollView and the other way is to convert the rect area?

Original source