Yalantis/Segmentio

Just trying to set it up but failed

Closed this issue · 4 comments

Hi,

I know it's embarrassing to ask but at the moment I start to feel that I have to.

I came across a few segmented controls and found Segmentio. It looks great so I want to use it in my own project.

Honestly, this has been the most frustrating tool I have ever tried.. Because after reading the tutorial, set up minimal things Segmentio needed and booted it up, it didn't work. Showing two big coloured box, as I configured, without responding to clicks...

it looks like it's frozen..

So then I tried to set Segmentio up with the options, carefully taking snippets from, again the tutorial without modifying anything, still it's frozen...

I started to doubt my life...

After played around it a while, I realised that if I set the height of the Segmentio view to 150, I would see things and it responds to click. However console is giving me this printout ever time a tab is clicked:

2017-08-06 04:14:22.447 app[53497:25921392] The behavior of the UICollectionViewFlowLayout is not defined because:
2017-08-06 04:14:22.448 app[53497:25921392] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
2017-08-06 04:14:22.448 app[53497:25921392] The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x7fd75862ee60>, and it is attached to <UICollectionView: 0x7fd75904f400; frame = (0 0; 414 150); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x618000250b30>; layer = <CALayer: 0x61800022ca20>; contentOffset: {0, -64}; contentSize: {552, 37}> collection view layout: <UICollectionViewFlowLayout: 0x7fd75862ee60>.
2017-08-06 04:14:22.448 app[53497:25921392] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

I started again, to doubt my life...

What I did was very basic. I set up a view in navigation controller, which is inside a tab view controller. So basically, above the Segmentio view, it's the navigation bar. Below the Segmentio view, it's a empty table view, below that, is the tab bar.

I used story board to set the class and IBOutlet. Nothing fancy..

Somebody please safe my life...

Thanks in advance.

My tab bar was frozen too until but I fixed it by specifying the SegmentioStates.
Basically I swapped this:

SegmentioStates(
    defaultState: SegmentioState(),
    selectedState: SegmentioState(),
    highlightedState: SegmentioState()
)

for the code in the README.md file:

SegmentioStates(defaultState: SegmentioState(backgroundColor: .clear, titleFont: UIFont.systemFont(ofSize: UIFont.smallSystemFontSize), titleTextColor: .black), 
	selectedState: SegmentioState( backgroundColor: .orange, titleFont: UIFont.systemFont(ofSize: UIFont.smallSystemFontSize), titleTextColor: .white), 
	highlightedState: SegmentioState( backgroundColor: UIColor.lightGray.withAlphaComponent(0.6), titleFont: UIFont.boldSystemFont(ofSize: UIFont.smallSystemFontSize), titleTextColor: .black)
)

And i can now click on the tab items.

@biogerm do you need more feedback on this issue?

sorry i switched to another tab tool about a week after I posted the question. I would come back later to try it out.

ok, than reopen it later if you would need it