Xlpagertabstrip: Bar does not show up anymore

Created on 16 Sep 2016  路  14Comments  路  Source: xmartlabs/XLPagerTabStrip

After upgrading my Xcode to 8.0 and my project to Swift 2.3, the Bar indicating the current view controller in my Bar Button Pager does not show up in 2 out of the 3 places in which I use this feature. As far as I can tell, they are all configured the same except for slight variation in sizing of the height of the Button Bar View.

I can still see the Indicator titles and functionality is fine.

Most helpful comment

@ashanatexilesoft I added this line and the buttonbar got visible again...

self.buttonBarView.collectionViewLayout = UICollectionViewFlowLayout()
self.buttonBarView.frame.size.height = 40

All 14 comments

Yeah its not working ... any remedy ??

I updated to Swift 3. Issue still remains.

My bar disappears when I use "add missing constraints" in storyboard but the title and everything is seems to be working fine. I'm also using swift 3.

I met the same bug.

Why

It is bcz in the function updateSlectedBarYPosition , selectedBar.frame is zero

How to fix it

I used code instead of Xib, I set frame as zero, now I set frame with screen.width. it worked.

let frame = CGRect(x: 0, y: 0, width: screenWidth, height: Constants.NavigationSwipBarHeight)
buttonBarView = ButtonBarView(frame: frame, collectionViewLayout: UICollectionViewFlowLayout())

I didn't use the stroyboard, I believe you can set the initial frame like this.

Anyone could fix it?

Any fix for anyone who used auto layout

@ashanatexilesoft I added this line and the buttonbar got visible again...

self.buttonBarView.collectionViewLayout = UICollectionViewFlowLayout()
self.buttonBarView.frame.size.height = 40

@anafinotti Yes! This made my bar appeared again. Thank you so much. :)

@anafinotti's solution worked for me too!

Seems to be an issue with the origin being incorrectly calculated. I added the following to the first line in updateSelectedBarPosition of ButtonBarView.swift:
selectedBar.frame.origin.y = self.frame.size.height - CGFloat(self.selectedBarHeight)

@anafinotti to which method did you add the lines in your solution?

after ViewDidLoad

add below code , it works to me

self.view.layoutIfNeeded()

buttonBarView.selectedBar.frame.origin.y = buttonBarView.frame.size.height - settings.style.selectedBarHeight

I may be reading this all wrong, but it appears that the original post was regarding the selected bar (i.e., the thin, orange bar in the ButtonBar and Bar type pager screenshots and examples). Some of the replies seem to be solving different problems. I too am seeing the missing selected bar issue, and was able to fix it using the code posted by @cruisediary. I added the code to viewDidLoad just after the call to super.viewDidLoad().

Some additional info. Prior to the fix the selected bar is present, just being clipped. You can see it using Xcode's View Debug Hierarchy and then selecting Show Clipped Views:

screen shot 2016-10-26 at 12 48 10 pm

Those of you who used @anafinotti 's solution, can you try switching the order of button bar and container view in storyboard? Set container to be first and button bar second. It seems adjust scroll view insets (which is on by default) causes this issue and there's no need for any workarounds.

Was this page helpful?
0 / 5 - 0 ratings