1
我有以下设置:iOS将视图以编程方式自动布局为子视图冲突约束
2故事板中定义的视图控制器。
我有一个自定义的segue,通过在第一个vc上激活一个控件来触发。
在-(void)perform
方法的segue,我不得不添加第二个vc的视图作为子视图与第一个动画。
-(void)perform{
MyVC *myVC = self.destinationViewController;
UIViewController *sourceVC = self.sourceViewController;
UIView *myView = myVC.view;
[sourceVC.view addSubview:myView];
NSDictionary *viewDictionary = NSDictionaryOfVariableBindings(sourceVC.view, drawerView);
[myView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"[myView(200)]"
options:0 metrics:nil views:viewDictionary]];
}
不幸的是我得到以下错误。
2014-10-31 16:57:33.899 ReviewsAgain[19971:5435238] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x7fb0306368c0 H:[UIView:0x7fb0306337e0(200)]>",
"<NSLayoutConstraint:0x7fb030635c80 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7fb0306337e0(375)]>"
)
我相信这里发生的一切 - myView
已应用在编译的时候它的约束“从自己的vc`,当我把它作为一个子视图添加到另一个观点 - 事情变得混乱和无法理解这就限制了应用 - 先前应用的那些 - 或我定义的那些。
我想知道解决这个问题的正确方法是什么?