I cannot get the coordinates of visible rectangle in scroll view after şt scrolls. So when I want to add a subview in a visible rect, I cannot. How can I do that?
CGRect visibleRect = CGRectMake(myScrollView.contentOffset.x, myScrollView.contentOffset.y, myScrollView.contentOffset.x + myScrollView.bounds.size.width, myScrollView.contentOffset.y + myScrollView.bounds.size.height)
This should get you the rect
that is currently visible, after scrolling.
Not what you must decide is, when you want to calculate the rect. If you want to get this on the fly, then do it in thescrollViewDidScroll
method. If you want to get it when user begins scrolling, then do it in scrollViewWillBeginDragging
. If you want it after the user is done scrolling and the scrollView
comes to rest, do it in scrollViewDidEndDragging
and scrollViewDidEndDecelerating
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With