Clear content of UIScrollView

前端 未结 6 444
盖世英雄少女心
盖世英雄少女心 2021-01-04 04:24

I have an iPhone application that uses a timer and at every time interval it creates some UILabel controls and adds them into a UIScrollView.

6条回答
  •  难免孤独
    2021-01-04 05:08

    You will also remove the scrollbar with the above solution. To solve this, you may ask whether the subview about to be removed is a UIImageView instance. Obviously, you will need to do more checks if you happen to have your own UIImageViews in the scroll view.

    for (UIView *subview in scrollView.subviews) {
      if(![subview isKindOfClass:[UIImageView class]])
        [subview removeFromSuperview];
    }
    

提交回复
热议问题