how do i remove all subviews from my scrollview...
i have a uiview and a button above it in the scrollview something like this....
here is my code to add sub
An old question; but as it's the first hit on Google for this I thought I'd also make a note that there's also this method:
[[myScrollView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
You can't do the isKindOfClass check with this, but it's still a good solution to know about.
Edit: Another point to note is that the scrollbar of a scrollview is added as a subview to that scrollview. Thus if you iterate through all the subviews of a scrollview you will come across it. If removed it'll add itself again - but it's important to know this if you're only expecting your own UIView subclasses to be in there.
Amendment for Swift 3:
myScrollView.subviews.forEach { $0.removeFromSuperview() }