module Teacup::Controller
Public Class Methods
included(base)
click to toggle source
# File lib/teacup/teacup_controller.rb, line 67 def self.included(base) base.extend ControllerClass end
Public Instance Methods
layoutDidLoad()
click to toggle source
# File lib/teacup/teacup_controller.rb, line 151 def layoutDidLoad end
root(stylename=nil, properties={})
click to toggle source
# File lib/teacup/teacup_controller.rb, line 91 def root(stylename=nil, properties={}) if stylename.is_a?(NSDictionary) properties = stylename stylename = nil end if stylename || properties layout(top_level_view, stylename, properties) else top_level_view end end
stylesheet=(new_stylesheet)
click to toggle source
Assigning a new stylesheet triggers {restyle!}.
Assigning a stylesheet is an alternative to returning a Stylesheet
in the {stylesheet} method. Note that {restyle!} calls {stylesheet}, so while assigning a stylesheet will trigger {restyle!}, your stylesheet will not be picked up if you don't return it in a custom stylesheet method.
@return Teacup::Stylesheet
@example
stylesheet = Teacup::Stylesheet[:main] stylesheet = :main
Calls superclass method
# File lib/teacup/teacup_controller.rb, line 84 def stylesheet=(new_stylesheet) super if self.viewLoaded? self.view.restyle! end end
teacupDidLoad()
click to toggle source
Instantiate the layout from the class, and then call layoutDidLoad.
If you want to use Teacup
in your controller, please hook into layoutDidLoad, not viewDidLoad or windowDidLoad (they call this method).
# File lib/teacup/teacup_controller.rb, line 108 def teacupDidLoad # look for a layout_definition in the list of ancestors layout_definition = nil my_stylesheet = self.stylesheet parent_class = self.class while parent_class != NSObject and not (layout_definition && my_stylesheet) if not my_stylesheet and parent_class.respond_to?(:stylesheet) my_stylesheet = parent_class.stylesheet end if not layout_definition and parent_class.respond_to?(:layout_definition) layout_definition = parent_class.layout_definition end parent_class = parent_class.superclass end should_restyle = Teacup.should_restyle_and_block if my_stylesheet and not self.stylesheet self.stylesheet = my_stylesheet end if layout_definition stylename, properties = layout_definition layout(top_level_view, stylename, properties) end if respond_to?(:teacup_layout) teacup_layout end layoutDidLoad if should_restyle Teacup.should_restyle! self.top_level_view.restyle! end if defined?(NSLayoutConstraint) self.top_level_view.apply_constraints end end