subinspathilettu / SJSegmentedViewController

MIT License
334 stars 126 forks source link

Missing argument for parameter 'coder' in call #43

Open alexeyRuin opened 7 years ago

alexeyRuin commented 7 years ago

Hello,

I have a menu item that should do select second segment in another ViewController where ProfileGlobalVC is. I tried to do it like: ProfileGlobalVC().setSelectedSegmentAt(2, animated: true) Xcode gives an error:

Missing argument for parameter 'coder' in call

Then I tried to do it that way: in my ProfileGlobalVC I've created a simple func: func listen() { self.setSelectedSegmentAt(2, animated: true) } And then tried ProfileGlobalVC().listen() Still getting the same error:

Missing argument for parameter 'coder' in call

My SJSegmentedViewController code is:

import UIKit
import SJSegmentedScrollView

class ProfileGlobalVC: SJSegmentedViewController, SJSegmentedViewControllerDelegate {

    var selectedSegment: SJSegmentTab?

    override func viewDidLoad() {
        self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
        self.navigationController?.navigationBar.shadowImage = UIImage()
        self.navigationController?.navigationBar.isTranslucent = false

        if let storyboard = self.storyboard {

            let headerController = storyboard
                .instantiateViewController(withIdentifier: "profile")

            let firstViewController = storyboard
                .instantiateViewController(withIdentifier: "offersTable")
            firstViewController.title = "Offers"

            let secondViewController = storyboard
                .instantiateViewController(withIdentifier: "fave")
            secondViewController.title = "Favourites"

            let thirdViewController = storyboard
                .instantiateViewController(withIdentifier: "settings")
            thirdViewController.title = "Settings"

            headerViewController = headerController
            segmentControllers = [firstViewController,
                                    secondViewController,
                                    thirdViewController]
            headerViewHeight = 180
            selectedSegmentViewHeight = 1.0
            segmentTitleColor = .gray
            selectedSegmentViewColor = .black
            segmentShadow = SJShadow.light()
            delegate = self

        }
        segmentViewHeight = 50
        title = "Segment"
        super.viewDidLoad()
}
SonnetXavier commented 7 years ago

Hi @alexeyRuin , Try adding the init() method in the other ViewController.

alexeyRuin commented 7 years ago

Hello, first of all sorry for long delay. init() didn't work for me.

I'm still having 'Missing argument' error.

NicholasBellucci commented 7 years ago

@alexeyRuin,

I had the same issue when creating my instance of my SJSegmentedViewController. Initially, I instantiated it with: var leftVC = SWPProfileViewController() . What helped me was to instead create the instance as an optional: var leftVC: SWPProfileViewController?

I hope this helps!

pratikgajbhiye222 commented 3 years ago

Any Help for this Error ? , its still ask for coder