sách gpt4 ăn đã đi

ios - swift 无法将类型 (_, _) -> _ 的值转换为预期的参数类型 '((_, CGFloat)) -> _

In lại 作者:搜寻专家 更新时间:2023-11-01 07:07:36 40 4
mua khóa gpt4 giày nike

我正在使用图书馆 URLEmbeddedView

它在其库中定义了以下代码:

func addConstraints(with view: UIView, center: CGPoint, multiplier: CGFloat = 1) {
view.translatesAutoresizingMaskIntoConstraints = false
addConstraints([
(.centerX, center.x),
(.centerY, center.y)
]
.flatMap {
.init(item: view,
attribute: $0,
relatedBy: .equal,
toItem: self,
attribute: $0,
multiplier: multiplier,
constant: $1)
})
}

我们正在通过库生成链接预览,但出现以下错误:

cannot convert value of type (_, _) -> _ to expected argument type '((_, CGFloat)) -> _" at .flapMap line.

我熟悉 Objective-C 但不熟悉 Swift。代码中会出现什么问题?

nhập mô tả hình ảnh ở đây

câu trả lời hay nhất

还需要使用8.1以上的Xcode版本。

我使用了与您相同的代码。只需将约束应用于 xem 即可完美运行。

   view.addConstraints([
(.centerX, center.x),
(.centerY, center.y)
].flatMap {
.init(item: view, attribute: $0, relatedBy: .equal, toItem: self, attribute: $0, multiplier: multiplier, constant: $1)
})

flatMap 语法没有问题。我已经在 Xcode-9Xcode-8 上执行了代码,它没有给我任何错误。

只是使用我在上面编写的相同代码,看看它是否可以正确编译。

关于ios - swift 无法将类型 (_, _) -> _ 的值转换为预期的参数类型 '((_, CGFloat)) -> _,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47069360/

40 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress