有一个令人困惑的问题:
我有一个视图控制器(settingsViewVontroller)
,它提供了另一个嵌入在导航控制器中的VC(colorPickerController
)。在iPhone上,settingsViewController以模态方式呈现。在iPad上,它以弹出窗口呈现在这两种情况下,导航控制器都以模态方式呈现,以覆盖设置ViewController - iPhone上的全屏,以及iPad上封闭的弹出窗口。
在ios7的两种情况下均可正常工作,但在ios6 for iPad上,它会尝试以模态方式显示包含颜色选择器的导航控制器。我收到一个自动布局错误,说无法协调约束,这似乎是导航栏的问题......
为什么这会在ios7上运行而不是6?
更新:部分代码:
从弹出窗口中,以模态方式呈现颜色选择器:
ColorPickerViewController *cpcontroller = [[ColorPickerViewController alloc] init];
cpcontroller.delegate = self;
cpcontroller.selectedColor = self.frameColorButton.backgroundColor;
cpcontroller.title = @"Frame Color";
UINavigationController* navVC = [[UINavigationController alloc] initWithRootViewController:cpcontroller];
navVC.delegate = self;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
navVC.modalPresentationStyle = UIModalPresentationCurrentContext;
//navVC.contentSizeForViewInPopover = CGSizeMake(320, 568);
//controller.contentSizeForViewInPopover = CGSizeMake(320,568);
//controller.view.translatesAutoresizingMaskIntoConstraints = NO;
}
[self presentViewController:navVC animated:YES completion:nil];
三条注释掉的线:我已经测试了每个“开”或“关”,没有变化。
以下是错误的文字:
2014-08-09 09:30:28.248 appname[16865:907] 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:0xa73dc70 H:[UINavigationBar:0xa992cb0]-(0)-| (Names: '|':UIView:0xa6db840 )>",
"<NSLayoutConstraint:0xa73dc30 H:|-(0)-[UINavigationBar:0xa992cb0] (Names: '|':UIView:0xa6db840 )>",
"<NSLayoutConstraint:0xa73fbd0 H:[UINavigationBar:0xa992cb0(320)]>",
"<NSAutoresizingMaskLayoutConstraint:0xa6dcfe0 h=--& v=--& UILayoutContainerView:0xa711050.width == UIView:0xa711370.width + 320>",
"<NSAutoresizingMaskLayoutConstraint:0xa6f5d40 h=-&- v=-&- UIView:0xa6db840.width == UILayoutContainerView:0xa711050.width>",
"<NSAutoresizingMaskLayoutConstraint:0xa6f86d0 h=--& v=--& H:[UIView:0xa711370(320)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0xa73fbd0 H:[UINavigationBar:0xa992cb0(320)]>
Break on objc_exception_throw to catch this in the debugger.