Sha256: 8012b2b78bb11155490a3f8b91ac5735dc0fcefaf561e8ff257e6bdbe06ba91d

Contents?: true

Size: 765 Bytes

Versions: 6

Compression:

Stored size: 765 Bytes

Contents

# Methods to retrieve a subview using the stylename as a key
# Kinda similar to jQuery-style $().find('stylename')
class UIView

  # get one stylesheet by stylename
  # my_view[:button] :button => #<UIButton..>
  def viewWithStylename name
    subviews.each do |view|
      if view.stylename == name
        return view
      end
    end
    subviews.each do |view|
      if v = view.viewWithStylename(name)
        return v
      end
    end
    nil  # couldn't find it
  end

  # get stylesheets by stylename
  # my_view.all :button => [#<UIButton..>, #<UIButton...>]
  def viewsWithStylename name
    r = []
    subviews.each do |view|
      if view.stylename == name
        r.push name
      end
      r += view.viewsWithStylename name
    end
    r
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
teacup-0.3.6 lib/teacup/z_core_extensions/ui_view_getters.rb
teacup-0.3.5 lib/teacup/z_core_extensions/ui_view_getters.rb
teacup-0.3.4 lib/teacup/z_core_extensions/ui_view_getters.rb
teacup-0.3.3 lib/teacup/z_core_extensions/ui_view_getters.rb
teacup-0.3.2 lib/teacup/z_core_extensions/ui_view_getters.rb
teacup-0.3.1 lib/teacup/z_core_extensions/ui_view_getters.rb