Skip to content

Instantly share code, notes, and snippets.

@pocketkk
Created July 21, 2014 20:42
Show Gist options
  • Select an option

  • Save pocketkk/01b57fa0d06892389c4c to your computer and use it in GitHub Desktop.

Select an option

Save pocketkk/01b57fa0d06892389c4c to your computer and use it in GitHub Desktop.
Swift Search Subview for UIScrollView
// Returns first UIScrollView in subviews of view
func searchFor(view: UIView) -> UIScrollView? {
for v in view.subviews{
let y = v as UIView
if v is UIScrollView {
return (v as UIScrollView)
}
}
return nil
}
func findScroller(viewToSearch: UIView) -> UIScrollView? {
for v in self.view.subviews {
if v is UIScrollView {
println("Found Scrollview")
return (v as UIScrollView)
} else {
if let s : UIScrollView? = searchFor(v as UIView) {
return s! as UIScrollView
}
}
}
println("No luck finding Scrollview")
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment