Skip to content

Instantly share code, notes, and snippets.

@sxross
Created February 22, 2013 00:04
Show Gist options
  • Save sxross/5009625 to your computer and use it in GitHub Desktop.
Save sxross/5009625 to your computer and use it in GitHub Desktop.
Teacup didMoveToSuperview Problem

backtrace

constraint.rb:112:in `from_sym:': Unknown symbol :topleft (RuntimeError)
  from ui_view.rb:87:in `block in get_ns_constraints'
	from ui_view.rb:82:in `get_ns_constraints'
	from ui_view.rb:152:in `block in get_ns_constraints'
	from ui_view.rb:151:in `get_ns_constraints'
	from ui_view.rb:152:in `block in get_ns_constraints'
	from ui_view.rb:151:in `get_ns_constraints'
	from ui_view.rb:165:in `apply_constraints'
	from ui_view.rb:269:in `didMoveToSuperview'

stylesheet.rb

  style :constrained_center,
    height: '80%',
    x: 10,
    constraints: [
      constrain(:center_y).equals(:superview, :center_y)
    ]

  style :v_centered_left_label, extends: :constrained_center,
    x: 10,
    width: '50%',
    constraints: [
      :topleft, :full_height,
      constrain(:width).equals(:superview, :width).times(0.6)
    ]

  style :v_centered_right_label, extends: :constrained_center,
    width: '40%',
    x: 150,
    constraints: [
      constrain(self, :left).equals(:v_centered_left_label, :right).plus(10)
    ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment