-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Set default tab or index #537
Comments
im having this same issue, can't seem to get a solution |
it's supposed to set preCurrentIndex = index if isViewLoaded is false, which it does, but that doesn't seem to actually set the default index |
Any news ? i have same problem |
Any updates on this problem? |
Just found a solution after some tackles.
|
|
Premise, you need the latest version of the library,This is very useful to me.
If no animation is needed
|
@ReverseScale , i have tried both variants in version 8.1.1, but it isn't works for me. I always make transition to first viewcontroller in collection. |
@Ultraa
I tried and succeed. BTW, I tried
then only tab moves to specified, but view controller didn't switch. |
Thank you for answer, i used code like @dexter199402 . It's succeed, but causes a sharp visible jump when opening XLPagerTabController. |
This is not a perfect solution, it can change currentIndex when controller is shown, but it cause controller's didLoad method. And in my test, when call moveToViewController the first button bar title is always selected. |
@zhpengkun my current workaround also fixes the initial menu being incorrectly set override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
DispatchQueue.main.async {
self.moveToViewController(at: 3, animated: false)
// needed or first tab stays highlighted
self.reloadPagerTabStripView()
}
} |
#537 (comment) almost works fine. But private var initialized = false
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
if initialized == false {
moveToViewController(at: 3, animated: false)
initialized = true
}
} |
You can call to @mistahenry's solution works, however its loads target ViewController twice. It may create some unwanted behaviors.
|
Using "moveToViewController" causes slider to be animated and moved from first tab to tab 3
how to make it set by default to tab 3 without moving ?
The text was updated successfully, but these errors were encountered: