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

Crashes when you change the segmentio listing. #118

Open
rupeshsaxena opened this issue Dec 19, 2018 · 0 comments
Open

Crashes when you change the segmentio listing. #118

rupeshsaxena opened this issue Dec 19, 2018 · 0 comments

Comments

@rupeshsaxena
Copy link

rupeshsaxena commented Dec 19, 2018

Report

I had a scenario of changing the datasource for the Segmentio tab, while selection an option updates the datasource by adding n number of tabs. But issue came when I switch the datasource. Let suppose I have currently 4 elements and when on tap of a button to change the datasource with 3 elements, it then crashes.

Please rectify this in Segmentio.swift line number 512 in function segmentWidth(for indexPath)
segment position - dynamic

if indexPath.row < segmentioItems.count {
    let itemWidth = Segmentio.intrinsicWidth(for: segmentioItems[indexPath.row], style: segmentioStyle)
    width = dynamicWidth > collectionViewWidth ? itemWidth
        : itemWidth + ((collectionViewWidth - dynamicWidth) / CGFloat(segmentioItems.count))
} else {
    let itemWidth = Segmentio.intrinsicWidth(for: segmentioItems[0], style: segmentioStyle)
    width = dynamicWidth > collectionViewWidth ? itemWidth
        : itemWidth + ((collectionViewWidth - dynamicWidth) / CGFloat(segmentioItems.count))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants