我使用UIAlertControllerStyleActionSheet创建了一个UIAlertController,然后添加了一些按钮,但提示我出现布局问题

时间:2019-07-13 09:53:02

标签: ios objective-c

我使用UIAlertControllerStyleActionSheet创建了一个UIAlertController,然后添加了一些按钮,但提示我遇到布局问题。我确定我的代码很好,但是我不知道问题出在哪里,如果您知道原因,请告诉我。 而且我将样式测试为UIAlertControllerStyleAlert,并且没有这个问题。

我的项目仅支持iphone,不支持iPad。我的开发环境:Xcode:10.2.1,iOS:12.3.1

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"title" message:@"message" preferredStyle:UIAlertControllerStyleActionSheet];

    UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:@"cancle" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
        //NSLog(@"");
    }];

    UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"sure" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        //NSLog(@"");
    }];

    [alertController addAction:cancleAction];
    [alertController addAction:sureAction];
    [self presentViewController:alertController animated:true completion:nil];

调试输出区域打印:

[LayoutConstraints] 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. 
(
    "<NSLayoutConstraint:0x282e9c5a0 UIView:0x1019286f0.width == -16>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x282e9c5a0 UIView:0x1019286f0.width == -16>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

0 个答案:

没有答案