[英]Removing subviews from UIScrollView
我需要從ScrollView
刪除圖像subviews
,並且嘗試從subviews
array
中刪除,但這是一個不可變的NSArray
。
如何從subview
的scrollviews array
中刪除subviews
?
NSArray *viewsToRemove = [scrollView subviews];
for (UIView *v in viewsToRemove) [v removeFromSuperview];
你可以這樣做,
[[scrollView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
這將刪除UIScrollView的所有子視圖,但會刪除其滾動指示器:_scrollView.showsHorizontalScrollIndicator = _scrollView.showsVerticalScrollIndicator = NO; [_scrollView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; _scrollView.showsHorizontalScrollIndicator = _scrollView.showsVerticalScrollIndicator =是;
for (UIView *v in [scrollView subviews]) {
[v removeFromSuperview];
}
迅速
for subview in scrollView.subviews {
subview.removeFromSuperview()
}
在子視圖上調用-removeFromSuperview。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.