Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
359 views
in Technique[技术] by (71.8m points)

swift - Error: Type of expression is ambiguous without more context Using Paper Onboarding

I am trying to use paper onboarding for my application but I am always getting the error "Type of expression is ambiguous without more context". I'm using Xcode 12. There's no error anywhere else except on the return part of the function "func onboardingItemsCount". I am fairly new to xcode so I'm not sure what I'm doing wrong. Any help would be appreciated. Here's part of the code:

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)
    
     }
}
question from:https://stackoverflow.com/questions/65895420/error-type-of-expression-is-ambiguous-without-more-context-using-paper-onboardi

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Would you please try this

let descriptionFont = UIFont(name: "AvenirNext-Regular", size: 18)!

instead of

let descriptionFont = UIFont(name: "AvenirNext-Regular", size: 18)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...