Best way to refresh/reload UIScrollView

前端 未结 6 2006
走了就别回头了
走了就别回头了 2021-01-04 05:59

I have a method that adds some subviews (images/buttons) to my ScrollView.

The thing is that from outside of the ScrollView the user can tap a button that will chang

6条回答
  •  遥遥无期
    2021-01-04 06:10

    Here is what I did to remove all subview except scrollbar, I removed all subviews that have frame.size.width greater than 10, scrollbar width is smaller than 10, so it will not be removed. This assumes that all the views that you add to UIScollView have a width greater than 10.

    for (UIView * view in view.subviews) {
        if(view.frame.size.width > 10){ // removes all component except scrollbar
            [view removeFromSuperview];
        }
    }
    

提交回复
热议问题