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

There should be an option to show the segment if viewControllers.count = 1 #29

Closed
alexookah opened this issue Feb 25, 2018 · 2 comments
Closed

Comments

@alexookah
Copy link
Contributor

Sometimes when having in most cases 2 or more Pages when the content is based dynamically on a server and some page fails you might have ended up in 1 viewController.
I see in your code you simply hide the segment.

i simply fixed this for me

/// Height of segmented indicator
/// Get only
open var scrollIndicatorHeight: CGFloat {
return viewControllers.count <= 1 ? perferredScrollIndicatorHeight : perferredScrollIndicatorHeight
}

/// Height of segmented control bar
/// Get only
open var segmentedControlHeight: CGFloat {
return viewControllers.count <= 1 ? preferredSegmentedControlHeight : preferredSegmentedControlHeight
}

Maybe there should be an option to show the segment in case it fails to 1 viewController in order to show the title to the user to know which page is he currently on.

What do you think?

@tungvoduc
Copy link
Owner

tungvoduc commented Feb 26, 2018

@alexookah My recommendation is that when you use DTPagerController, always subclass it, create your own, customise everything in your class and use it throughout your application. For example, you can do something like this instead of changing directly in my source code:


class PagerController: DTPagerController {

    // Fixed scroll indicator height
    override var scrollIndicatorHeight: CGFloat {
        return perferredScrollIndicatorHeight
    }
    
    // Fixed segmented control height
    override var segmentedControlHeight: CGFloat {
        return preferredSegmentedControlHeight
    }

    override init(viewControllers: [UIViewController]) {
        super.init(viewControllers: viewControllers)
        
        // Other customizations
        font = UIFont.customFont(15)
        selectedFont = UIFont.boldCustomFont(15)
    }

}

@alexookah
Copy link
Contributor Author

Thanks a lot for your recommendation. 👍
will try it out!

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

2 participants