Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/112.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用NSLAYOUTACHOR.constraintEqualToSystemSpacingAfter时出现控制台警告_Ios_Swift_Ios11_Nslayoutconstraint_Nslayoutanchor - Fatal编程技术网

Ios 使用NSLAYOUTACHOR.constraintEqualToSystemSpacingAfter时出现控制台警告

Ios 使用NSLAYOUTACHOR.constraintEqualToSystemSpacingAfter时出现控制台警告,ios,swift,ios11,nslayoutconstraint,nslayoutanchor,Ios,Swift,Ios11,Nslayoutconstraint,Nslayoutanchor,我正在使用nslayoutachor的constraintEqualToSystemSpacingAfter构建我的布局 NSLayoutConstraint.activate([ customView.leadingAnchor.constraintEqualToSystemSpacingAfter(safeAreaLayoutGuide.leadingAnchor, multiplier: 1) ]) 它实际上可以工作,但在我激活约束后,它会在控制台中抛出一个警告: 对齐[自定义视

我正在使用
nslayoutachor
constraintEqualToSystemSpacingAfter
构建我的布局

NSLayoutConstraint.activate([
    customView.leadingAnchor.constraintEqualToSystemSpacingAfter(safeAreaLayoutGuide.leadingAnchor, multiplier: 1)
])
它实际上可以工作,但在我激活约束后,它会在控制台中抛出一个警告:

对齐[自定义视图]的右边缘 具有[第二个自定义视图]的右边缘 不建议使用。对约束使用显式常量以替代此值


如何使此警告消失?

使用
nslayoutachor.constraint(equalTo:constant:)
代替该方法

NSLayoutConstraint.activate([
    customView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor, constant: 0)
])