【发布时间】:2021-01-26 03:15:26
【问题描述】:
我正在尝试为我的应用程序使用纸质入门,但我总是收到错误消息“表达式类型不明确,没有更多上下文”。我正在使用 Xcode 12。除了函数“func onboardingItemsCount”的返回部分外,其他任何地方都没有错误。我对 xcode 相当陌生,所以我不确定我做错了什么。任何帮助,将不胜感激。以下是部分代码:
func onboardingItemsCount() -> Int {
return 3
}
func onboardingItem(at index: Int) -> OnboardingItemInfo {
let backgroundColorOne = UIColor(red: 217/255, green: 72/255, blue: 89/255, alpha: 1)
let backgroundColorTwo = UIColor(red: 106/255, green: 166/255, blue: 211/255, alpha: 1)
let backgroundColorThree = UIColor(red: 168/255, green: 200/255, blue: 78/255, alpha: 1)
let titleFont = UIFont(name: "AvenirNext-Bold", size: 24)!
let descriptionFont = UIFont(name: "AvenirNext-Regular", size: 18)
return [
OnboardingItemInfo(informationImage: "image_1",
title: "Healthy + Food",
description: "Quickly search and add healthy foods",
pageIcon: "",
color: backgroundColorOne,
titleColor: UIColor.white,
descriptionColor: UIColor.white,
titleFont: titleFont,
descriptionFont: descriptionFont),
OnboardingItemInfo(informationImage: "image_2",
title: "Healthy + Cart",
description: "Add items to your cart",
pageIcon: "",
color: backgroundColorTwo,
titleColor: UIColor.white,
descriptionColor: UIColor.white,
titleFont: titleFont,
descriptionFont: descriptionFont),
OnboardingItemInfo(informationImage: "image_3",
title: "Healthy + Delivery",
description: "View Markets in your area",
pageIcon: "",
color: backgroundColorThree,
titleColor: UIColor.white,
descriptionColor: UIColor.white,
titleFont: titleFont,
descriptionFont: descriptionFont)
] [index] (Error: Type of expression is ambiguous without more context)
}
}
【问题讨论】: