Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scrollToPage not working when called from parent viewcontroller #231

Open
sumitpaul opened this issue Sep 25, 2019 · 1 comment
Open

scrollToPage not working when called from parent viewcontroller #231

sumitpaul opened this issue Sep 25, 2019 · 1 comment

Comments

@sumitpaul
Copy link

I have a parent view controller with a container view that has a pageboy viewcontroller embedded in it. I have next/previous buttons in the parent viewcontroller, as I don't want the buttons to slide with the pages embedded in the pageboy viewcontroller. But when I try to call the scrollToPage functions in the parent nothing happens. What am I doing wrong?

My code:`

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "CarouselEmbedSegue" {
        let vc = segue.destination as! ContainedCarouselVC
        guard let selectedLocation = location else { return }
        vc.themeColor = selectedLocation.color
        vc.locationToLoad = selectedLocation
    }
}

@IBAction func slidePrevious(_ sender: Any) {
    let vc =  ContainedCarouselVC()
    vc.scrollToPage(.previous, animated: true)
}

@IBAction func slideNext(_ sender: Any) {
    let vc = ContainedCarouselVC()
    vc.scrollToPage(.next, animated: true)
}

`

@sugitatestblue
Copy link

sugitatestblue commented Jan 14, 2022

@sumitpaul

You created new instance in slidePrevious and slideNext methods.
let vc = ContainedCarouselVC()

if you refer to ContainedCarouselVC's instance. I guess it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants