Xlpagertabstrip: There will be wide space under buttonBarView when swipe to switch view controllers

Created on 22 Dec 2016  Â·  16Comments  Â·  Source: xmartlabs/XLPagerTabStrip

Hi,

Recently, I updated to Swift 3 and upgrading to XLPagerTabStrip 6.0.0.
I am using Xcode 8 and Swift 3.0.2 based codebase.
And I found if I swipe to switch view controllers from left to right or from right to left, there was wide space under buttonBarView, like the red box in image below indicated,
however, clicking items in buttonBarView would not cause such phenomenon.
I tried to trace the containerView's content size,
the "y" offset changed to -64 when using swipe, which is expected to be 0, so I think this would be the reason why there was wide space under buttonBarView.
Then I wonder how this issue can be solved.
Can someone be helpful, and I will be grateful.

Thanks!

iphone7plus

awaiting response

Most helpful comment

+1 for this

Hi @mtnbarreto
yep, I'm also using interface builder to create the pager controller

edit:

found a fix guys! from #200
Disable "Adjust Scroll View Insets" in your viewcontroller

All 16 comments

Same problem here

Same problem too, i can't solve it.

same problem, any solutions?

I ended up removing the framework and creating my own slide. It went great, if you guys are interested I'll show you

Would like to take a look at it. Thanks!

-Merve

On 22 Jan 2017, at 11:18, Fer Frassia notifications@github.com wrote:

I ended up removing the framework and creating my own slide. It went great, if you guys are interested I'll show you

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

I just coded a sample:
https://github.com/FerFrassia/iOS/tree/master/PagerSample

Just fork it, cheers!

Guys, Are you using Interface builder to create the pager controller?

hey @mtnbarreto!

Yeah, I was using it.
Could it have been a recent change to Swift 3 that made the bug?

+1 for this

Hi @mtnbarreto
yep, I'm also using interface builder to create the pager controller

edit:

found a fix guys! from #200
Disable "Adjust Scroll View Insets" in your viewcontroller

Setting self.automaticallyAdjustsScrollViewInsets = false in the viewDidLoad of the ButtonBarPagerTabStripViewController derived class appears to have resolved this issue for me.

no luck, after adding self.automaticallyAdjustsScrollViewInsets = false in the viewDidLoad of ButtonBarPagerTabStripViewController derived class.
Still the bug exists.

Have the same issue. automaticallyAdjustsScrollViewInsets doesn't help.

Hi!

Are you using a UITableViewController as a childViewController? This issue seems to happen in this case.

To fix this issue, you should be setting automaticallyAdjustsScrollViewInsets = false and also having as childViewControllers only UIViewControllers with a UITableView inside, instead of UITableViewController.

Hope it helps! Regards,

Hi, @fedeojeda95

I am using [UIViewController] array with a collection view inside each of them. Initializing with storyboards.
The issue is happening on all of them except for the first one.

Hi @AgapovOne

I tried reproducing your issue by creating a UIViewController and with interface builder I added a UICollectionView to it, add some constraints and set the outlet. I seemed to have no issue with the top space, it was just next to the top. Could you further tell what's the problem and maybe post some code?

Cheers

@fedeojeda95
I have debugged this behavior.
Used default ButtonBarPagerTabStripViewController. It seems the issue happened was wrong layout margins of containerView: UIScrollView's contentView. It had edge insets with 8 points on each side.

Fixed it by adding this:

// file: PagerTabStripViewController.swift
// method: updateContent()
open func updateContent() {
...
                    childController.view.autoresizingMask = [.flexibleHeight, .flexibleWidth]
                    childController.view.layoutMargins = .zero // added this line.
                    containerView.addSubview(childController.view)
...

Not sure if it won't break other behavior with library, but it helped in my current situation.

_Also, that's strange, but this issue seems to happen on 2 modules of 3. The last one works great._

_The issue is fixed itself after moving pushing to next viewcontroller and popping back. Top space is removed._

This is the issue: (top white space below button bar)
screen shot 2017-05-16 at 10 54 47

Easy solution: _(not sure if it will help others)_
Also, this issue can be fixed. Found that I was setting constraints of UIViewController's UICollectionView with top = topMargin. Removed margin part, it worked.

Was this page helpful?
0 / 5 - 0 ratings