Error: Type of expression is ambiguous without more context Using Paper Onboarding
Error: Type of expression is ambiguous without more context Using Paper Onboarding
我正在尝试为我的应用程序使用纸质入职培训,但我总是收到错误“表达式类型不明确,没有更多上下文”。我正在使用 Xcode 12。除了函数“func onboardingItemsCount”的 return 部分外,其他任何地方都没有错误。我是 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)
}
}
你能试试这个吗
let descriptionFont = UIFont(name: "AvenirNext-Regular", size: 18)!
而不是
let descriptionFont = UIFont(name: "AvenirNext-Regular", size: 18)
我正在尝试为我的应用程序使用纸质入职培训,但我总是收到错误“表达式类型不明确,没有更多上下文”。我正在使用 Xcode 12。除了函数“func onboardingItemsCount”的 return 部分外,其他任何地方都没有错误。我是 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)
}
}
你能试试这个吗
let descriptionFont = UIFont(name: "AvenirNext-Regular", size: 18)!
而不是
let descriptionFont = UIFont(name: "AvenirNext-Regular", size: 18)