yysskk / SwipeMenuViewController

Swipable tab and menu View and ViewController.
MIT License
1.29k stars 131 forks source link

jump to specific index of page failed #100

Closed sharedcare closed 2 years ago

sharedcare commented 4 years ago

I wrote following method in my code. However jump function does not work in this situation, it only jumps to the second page.

func swipeMenuView(_ swipeMenuView: SwipeMenuView, viewDidSetupAt currentIndex: Int) {
        swipeMenuView.jump(to: selectedPage, animated: true)
    }
curiousurick commented 4 years ago

I'm having the same issue.

jameszyao commented 4 years ago

the same issue

ericosg commented 4 years ago

Here's how I fixed it, hopefully helps you too:

Change public func jump: in SwipeMenuView.swift:


    public func jump(to index: Int, animated: Bool) {
         guard let tabView = tabView, let contentScrollView = contentScrollView else { return }
         if currentIndex != index {
             delegate?.swipeMenuView(self, willChangeIndexFrom: currentIndex, to: index)
+            isJumping = true // This was added to fix the jump() as it wasn't working
+        } else {
+            // This was added to fix the jump() as it wasn't working
+            isJumping = false
         }
         jumpingToIndex = index
         tabView.jump(to: index)
         contentScrollView.jump(to: index, animated: animated)
     }
ericosg commented 3 years ago

Here's how I fixed it, hopefully helps you too:

Change public func jump: in SwipeMenuView.swift:

    public func jump(to index: Int, animated: Bool) {
         guard let tabView = tabView, let contentScrollView = contentScrollView else { return }
         if currentIndex != index {
             delegate?.swipeMenuView(self, willChangeIndexFrom: currentIndex, to: index)
+            isJumping = true // This was added to fix the jump() as it wasn't working
+        } else {
+            // This was added to fix the jump() as it wasn't working
+            isJumping = false
         }
         jumpingToIndex = index
         tabView.jump(to: index)
         contentScrollView.jump(to: index, animated: animated)
     }

This shouldn't be considered a fix, nor does it seem to be fixed otherwise, but as a solution it might help. It's causing more problems for me so I won't recommend the above.

bellebethcooper commented 2 years ago

I made a fork and a couple of very small changes fixed this issue for me. Here's the commit that got jumping to a specific index working for me.

sharedcare commented 2 years ago

@bellebethcooper 's method works for me.