我正在尝试以编程方式在我的iOS应用中使用autolayout.我有一个简单的视图控制器与此初始化代码
UIView *innerView = [[UIView alloc] initWithFrame:self.view.bounds];
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button1 setFrame:CGRectMake(50, 50, 150, 50)];
[button1 setTitle:@"button1" forState:UIControlStateNormal];
UIButton *button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button2 setFrame:CGRectMake(250, 50, 150, 50)];
[button2 setTitle:@"button2" forState:UIControlStateNormal];
[innerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[button1][button2(==button1)]|" options:NSLayoutFormatAlignAllBaseline metrics:0 views:NSDictionaryOfVariableBindings(button1, button2)]];
[innerView addSubview:button1];
[innerView addSubview:button2];
[self.view addSubview:innerView];
Run Code Online (Sandbox Code Playgroud)
但是当我试图运行它时,我收到了这个错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse constraint format:
Unable to interpret '|' character, because the related view doesn't have a superview
|[button1][button2(==button1)]|
^'
Run Code Online (Sandbox Code Playgroud)
它出什么问题了?
当我试图移除管道时constraintsWithVisualFormat,我收到此警告:
Unable …Run Code Online (Sandbox Code Playgroud) 我对Expression Blend 4有疑问.
我想创建一个简单的组件出现动画,当组件的高度从0变为100%,而它下面的组件向下移动以分配所需的空间.
我的问题是只允许以像素为单位的静态值来创建这种类型的动画.但我不知道我的控制高度(实际上,它是内容和内容长度可能不同的textBox),我无法设置Height最后一个关键帧的值Auto.
我该怎么做才能完成这项任务?
提前致谢.