Giter Site home page Giter Site logo

Comments (6)

kazuhiro4949 avatar kazuhiro4949 commented on June 12, 2024 1

@finlayjn thanks for your help. I fixed the issue.

from pagingkit.

kazuhiro4949 avatar kazuhiro4949 commented on June 12, 2024

@longunidev I'm sorry for the late reply. Could you show me the code snippet?

from pagingkit.

finlayjn avatar finlayjn commented on June 12, 2024

Just ran into the same issue. My code is very closely based on the Reloadable example, but I can send some if it helps. For me, the issue seems to arise from adding and removing view controllers from the data source. I implemented the following workarounds:

Reset the underline when updating the data source:

var dataSource = [(menu: String, content: UIViewController)]() {
        didSet {
            menuViewController?.reloadData()
            contentViewController?.reloadData()
            menuViewController?.focusView.subviews.forEach {$0.removeFromSuperview()}
            menuViewController?.registerFocusView(view: UnderlineFocusView())
        }
    }

Scrolling away before removing a page also seems to help:

let closingIndex = menuViewController?.currentFocusedIndex
// Scroll to next page to the left if closing the rightmost page
if closingIndex == dataSource.count - 1 && dataSource.count > 1 {
    menuViewController?.scroll(index: closingIndex! - 1, animated: true)
    contentViewController?.scroll(to: closingIndex! - 1, animated: true)
// Otherwise, scroll to next page to the right
} else if dataSource.count > 1 {
    menuViewController?.scroll(index: closingIndex! + 1, animated: true)
    contentViewController?.scroll(to: closingIndex! + 1, animated: true)
    menuViewController?.scroll(index: closingIndex!, animated: false)
    contentViewController?.scroll(to: closingIndex!, animated: false)
}
dataSource.remove(at: (closingIndex)!)

from pagingkit.

kazuhiro4949 avatar kazuhiro4949 commented on June 12, 2024

@finlayjn Thanks. I'm going to try to reproduce the issue.

from pagingkit.

kazuhiro4949 avatar kazuhiro4949 commented on June 12, 2024

@finlayjn I couldn't reproduce the issue with MenuReloadableViewController. Could you give me any additional information?

from pagingkit.

finlayjn avatar finlayjn commented on June 12, 2024

Sure. Like I said I think it's an issue with updating the data source. More specifically, it seems to occur when the data source is empty and an item is added. Here's the changes I made to reproduce the issue in the MenuReloadableViewController example in the sample project:

Change "menus" constant to a variable and leave it empty to begin.

var menus: [String] = []

Add this line to the reloadButtonDidTap action before updating dataSource.

self.menus.append("Menu")

Run the app and press the Reload button. The first menu item that appears will not be aligned with its underline.
Simulator Screen Shot - iPhone 12 Pro - 2021-05-16 at 16 54 21

from pagingkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.