You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

集成Paper Onboarding至App时遇Argument labels '(itemsCount:)'重载不匹配错误求助

Fixing "Argument labels '(itemsCount:)' do not match any available overloads" in Paper Onboarding

Hey there! Let's work through this Paper Onboarding error together. That message usually means the method/initializer signature you're using doesn't align with what the current version of the library expects. Here are the most common fixes:

Common Causes & Solutions

  • The library updated its API
    Most recent versions of Paper Onboarding have moved away from directly passing an itemsCount parameter to using a dataSource protocol. If you were following an older tutorial, your code is likely using deprecated syntax. Instead of initializing with itemsCount, you'll need to conform to the PaperOnboardingDataSource protocol to supply your onboarding content.

    Here's a modern implementation example:

    import UIKit
    import PaperOnboarding
    
    class OnboardingViewController: UIViewController, PaperOnboardingDataSource {
        // Define how many onboarding items you have
        func onboardingItemsCount() -> Int {
            return 3
        }
    
        // Provide details for each onboarding item
        func onboardingItem(at index: Int) -> OnboardingItemInfo {
            let image = UIImage(named: "onboarding-image-\(index)") ?? UIImage()
            let icon = UIImage(named: "onboarding-icon-\(index)") ?? UIImage()
            
            return OnboardingItemInfo(
                informationImage: image,
                title: "Step \(index + 1)",
                description: "Your detailed description for this onboarding step",
                pageIcon: icon,
                color: index == 0 ? .systemBlue : index == 1 ? .systemGreen : .systemOrange,
                titleColor: .white,
                descriptionColor: .white,
                titleFont: UIFont.boldSystemFont(ofSize: 22),
                descriptionFont: UIFont.systemFont(ofSize: 16)
            )
        }
    
        override func viewDidLoad() {
            super.viewDidLoad()
            
            let onboardingView = PaperOnboarding()
            onboardingView.dataSource = self
            onboardingView.translatesAutoresizingMaskIntoConstraints = false
            view.addSubview(onboardingView)
    
            // Pin the onboarding view to fill the screen
            NSLayoutConstraint.activate([
                onboardingView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
                onboardingView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
                onboardingView.topAnchor.constraint(equalTo: view.topAnchor),
                onboardingView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
            ])
        }
    }
    
  • You're calling the wrong initializer
    Double-check that you're using the correct initializer for your library version. If you're using an older version where itemsCount was valid, ensure you haven't accidentally updated the library without adjusting your code. You can either pin the library to the older version (via CocoaPods, Swift Package Manager, etc.) or update your code to match the latest API.

  • Verify your library setup
    Make sure you've installed the library correctly and that your dependency manager (CocoaPods, SPM) is pulling the version you expect. Check the library's repository README for the exact syntax matching your installed version.

If you're still stuck, share a snippet of the code where you're getting the error, and we can narrow it down further!

内容的提问来源于stack exchange,提问作者Bruna Anjos

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 07:01:14