【发布时间】:2013-10-25 20:45:01
【问题描述】:
我正在尝试在 RubyMotion 项目中混合运动布局和茶杯。我创建了一个示例视图助手来说明我的问题:
module Teacup::Layout
def example(name, options = {})
subview UIView, name do
subview UILabel, "#{name}_label".to_sym, text: options[:label]
auto do
horizontal "|-[#{name}_label]-|"
end
end
end
end
当我在 layout 块内调用 example(:example), text: "Test" 时,我的代码会引发以下异常:
(main)> 2013-10-25 13:40:45.989 rui[55552:80b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse constraint format:
example_label is not a key in the views dictionary.
H:|-[example_label]-|
如果我省略运动布局代码并检查视图,example_label 视图是 example 视图的子视图。这是怎么回事?
【问题讨论】:
-
也许尝试使用字符串而不是符号?我不是自动布局专家。
-
不幸的是,这并没有成功。
-
我认为这段代码应该可以工作,明天我会玩它! :-)
标签: autolayout rubymotion