Swift中的不明确且没有更多上下文错误

Swift中的不明确且没有更多上下文错误,swift,Swift,我刚刚更新了Swift,我在这些行中遇到了一个错误 错误1: 表达式类型“[(nslayouttribute,Double)]不明确,没有更多上下文 错误2: 表达式类型“[(NSLayoutAttribute,Int)]不明确,没有更多上下文 您似乎将函数声明为接受 (attribute: NSLayoutAttribute, offset: CGFloat) 但是你通过了 (attribute: NSLayoutAttribute, offset: int) 试一试 Int不能直接转换为

我刚刚更新了Swift,我在这些行中遇到了一个错误

错误1:

表达式类型“[(nslayouttribute,Double)]不明确,没有更多上下文

错误2:

表达式类型“[(NSLayoutAttribute,Int)]不明确,没有更多上下文


您似乎将函数声明为接受

(attribute: NSLayoutAttribute, offset: CGFloat)
但是你通过了

(attribute: NSLayoutAttribute, offset: int)
试一试


Int不能直接转换为float

您似乎将函数声明为接受
(属性:nslayouttribute,偏移量:CGFloat)
,但您传递
(属性:nslayouttribute,偏移量:Int)
,尝试[(nslayouttribute.centerX,CGFloat(0)),(nslayouttribute.centerY,CGFloat(30))]感谢用户9335240这解决了我的问题。您在类型声明上有标签,但没有元组文本,请尝试添加它们。如果@user9335240的注释解决了您的问题,您可以删除您的问题,或者让他/她将注释作为答案发布,以便其他具有相同问题的人可以快速找到答案。
(attribute: NSLayoutAttribute, offset: CGFloat)
(attribute: NSLayoutAttribute, offset: int)
[(NSLayoutAttribute.centerX, CGFloat(0)), (NSLayoutAttribute.centerY, CGFloat(30))]