ios - 使用纸质入职时出错

标签 ios swift

我一直在关注 Youtube 上的这个教程:https://www.youtube.com/watch?v=G5UkS4Mrepo但我在返回时不断收到以下错误并且找不到解决方案:

Cannot convert return expression of type '(String, String, String, String, UIColor, UIColor, UIColor, UIFont, UIFont)' to return type 'OnboardingItemInfo' (aka '(imageName: UiImage, title: String, description: String, iconName: UiImage, color: UIColor, titleColor: UIColor, descriptionColor: UIColor, titleFont: UIFont, descriptionFont: UIFont)')

在 15:13 分钟左右,他根据他提供的代码展示了一个正常运行的应用程序,但我的应用程序却抛出错误。这是我的代码:

...

@IBOutlet weak var onboardingView: OnboardingView!

override func viewDidLoad() {
    super.viewDidLoad()
    onboardingView.dataSource = self
}

func onboardingItemsCount() -> Int {
    return 3
}

func onboardingItemAtIndex(_ 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)

    return[
        ("rocket", "a great rocket start", "text description", "", backgroundColorOne, UIColor.white, UIColor.white, titleFont, descriptionFont)
    ][index]
}

...

文档可在此处找到:https://cdn.rawgit.com/Ramotion/paper-onboarding/master/docs/index.html

最佳答案

根据错误消息,返回的元组中的第 1 个和第 4 个值需要属于 UIImage 类型,而不是 String。设计此 API 的人在这两个值的命名约定方面做得很差。

另请注意,您已指定有 3 个项目,但您的 onboardingItemAtIndex 只有一个值数组。

关于ios - 使用纸质入职时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44998988/

相关文章:

ios - 文件路径中可选值的解包错误

ios - 设置 statusbarStyle(在 iOS 9.0 中已弃用)

ios - 我可以使用 Apple 开发人员证书作为 SSL 服务器证书吗

iphone - 将网络应用程序添加到主屏幕

ios - 如何从另一个 View Controller 更改文本?

swift - 检查 AnyClass 变量是否是类的扩展或实现

ios - AppCode 不提示 RxSwift 类和其他一些已安装的 CocoaPods

ios - 在同一天快速安排 UILocalNotification

ios - React Native 使用设备上的预捆绑文件,即使是 DEV 模式

ios - 删除以前在 Swift 中从同一个应用程序存储的健康数据?