简体   繁体   中英

How can a UIView subclass get notified when it has been scrolled by its Superview UIScrollView

I am trying to subclass UIView and to get notified when its superviews got scrolled. I tried with UIScrollView DidScroll delegate, But I want to create a standalone UIView to handle its movement on screen by itself. I tried by iterating its superviews and adding KVO for each superviews, but it might lead to performance issues. Can you please suggest some better solution for this?

You can create a protocol for delegation, that you can set in parent UIViewController and implement function in sub view class. and call these protocol function from UIScrollView delegate method.

This should solve your problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM