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

Wrong x offset for view controller #575

Closed
nplkhn opened this issue May 24, 2021 · 6 comments
Closed

Wrong x offset for view controller #575

nplkhn opened this issue May 24, 2021 · 6 comments

Comments

@nplkhn
Copy link

nplkhn commented May 24, 2021

I have an issue then i rotate screen the x offset calculates with mistake and view controller from the next page appears on the second half of the first page.

My paging view controller embedded in a navigation controller. That navigation controller added as a child view controller to other view controller that also embedded in navigation view controller.

If I have only one navigation controller everything works good.

@Starsky89
Copy link

Starsky89 commented Aug 1, 2021

I found the solution to this problem:
Call this function inside the subclassed object of type PagingViewController:

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransition(to: size, with: coordinator)
        
    self.pageViewController.willTransition(to: view.traitCollection, with: coordinator)
}

@rechsteiner
Can I ask you if this is intentional, or was it a mistake.
In the file PageViewController.swift, there is this override method:

public override func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) {
    super.willTransition(to: newCollection, with: coordinator)
    coordinator.animate(alongsideTransition: { _ in
        self.manager.viewWillTransitionSize()
    })
}

I wonder if this should have been an override for this function?

public override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransition(to: size, with: coordinator)
        
    coordinator.animate(alongsideTransition: { _ in
        self.manager.viewWillTransitionSize()
    })
}

This would solve the problem we're having on iPads when rotating the device, the underlying scrollView's content width should be updated.

@georgenhari
Copy link

yeah thank you, the other method actually is never called

@rechsteiner
Copy link
Owner

Ahh yes, that definitely looks like a mistake. Will get that fixed soon!

@rechsteiner
Copy link
Owner

I've fixed some issues with rotation when using the SwiftUI wrapper in #596. Could you target the master branch and see if that fixes your issues?

@Starsky89
Copy link

@rechsteiner
Yeah, it looks like this fixes the problem with rotation.

P.S: You might want to remove the print statement on line 171
print("viewWillTransition: ", size) inside PageViewController.swift

@rechsteiner
Copy link
Owner

A new version is out now that fixes this v3.1.0. @Starsky89 I forgot to remove the print statement in this release, but it's fixed in the master branch

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

No branches or pull requests

4 participants