Advertisement
robihamanto

UIScrollView nested scrolling solution

Dec 16th, 2020
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.76 KB | None | 0 0
  1. import Foundation
  2.  
  3.  
  4. func scrollViewDidScroll(_ scrollView: UIScrollView) {
  5.     if scrollView == rootScrollView {
  6.         if isParentViewCanScroll == false {
  7.             rootScrollView.contentOffset.y = headerStickyHeight // point A
  8.             isChildViewCanScroll = true
  9.         } else if scrollView.contentOffset.y >= headerStickyHeight {
  10.             rootScrollView.contentOffset.y = headerStickyHeight
  11.             isParentViewCanScroll = false
  12.             isChildViewCanScroll = true
  13.         }
  14.     } else {
  15.         if isChildViewCanScroll == false {
  16.             childScrollView.contentOffset.y = 0 // point B
  17.         } else if scrollView.contentOffset.y <= 0 {
  18.             isChildViewCanScroll = false
  19.             isParentViewCanScroll = true
  20.         }
  21.     }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement