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 is a white space above my child controllers #264

Closed
junweimah opened this issue Mar 21, 2018 · 22 comments
Closed

There is a white space above my child controllers #264

junweimah opened this issue Mar 21, 2018 · 22 comments
Labels

Comments

@junweimah
Copy link

Coming from

So I have solved the bug stated there, now I am using these codes in my initializeViewControllers :

let storyboard = UIStoryboard(name: "Landing", bundle: Bundle.main)
        var viewControllers = [UIViewController]()
        var barItems = [Item]()

        for index in 0 ..< count {
            var viewControllerChild = UIViewController()
            switch index{
            case 0:
                viewControllerChild = storyboard.instantiateViewController(withIdentifier: "Me_Favourites_CollectionView_SBID") as! MeFavouritesCollectionViewController
                barItems.append(Item(title: StringResource.Favourites))
            case 1:
                viewControllerChild = storyboard.instantiateViewController(withIdentifier: "Wallet_Reload_SBID") as! WalletReloadViewController
                barItems.append(Item(title: StringResource.Vouchers))
            case 2:
                viewControllerChild = storyboard.instantiateViewController(withIdentifier: "Me_Events_CollectionView_SBID") as! MeEventsCollectionViewController
                barItems.append(Item(title: StringResource.Events))
            default :
                break
            }
            //            viewController.index = index + 1
            viewControllers.append(viewControllerChild)
        }
        
        bar.items = barItems
        self.viewControllers = viewControllers

When I land on my parent vc, there is a white space between the child and the custom UIView from the parent vc. And scrolling left and right will remove the white space. I have recorded 2 videos and sent you through email, please have a look.

@electic
Copy link

electic commented Mar 21, 2018

I am having this issue as well. Did anyone find a fix for this? Basically, if I scroll away, and then come back to the view, the content is offset to the top of the screen. However, the uI scrollview is not at the top. So basically there is a gap of blank space on the top. Wiggling the pager gets the content to go to the true page's top.

@msaps
Copy link
Member

msaps commented Mar 21, 2018

@electic @junweimah is this present on the later version of AutoInsetter (1.2.2)?

Sent with GitHawk

@electic
Copy link

electic commented Mar 21, 2018

So I just forced updated the podfile to 1.2.2 and yah, it is still there.

@electic
Copy link

electic commented Mar 21, 2018

So here is the intital state:

https://pasteboard.co/HcZ1d8P.jpg

I scroll down and then I then slighly wiggle the pager.

https://pasteboard.co/HcZ1qPW.jpg

Notice the content in moves in this shot. Then I scroll up and you see the gap.

https://pasteboard.co/HcZ0Tnv.jpg

@electic
Copy link

electic commented Mar 21, 2018

So I got it to work by changing something in the tabman file:

`
open override func viewDidLoad() {
super.viewDidLoad()

    // configure for auto insetting
    //self.automaticallyAdjustsScrollViewInsets = !automaticallyAdjustsChildViewInsets
    autoInsetter.isEnabled = false

`

This seems to fix it. Not sure if this helps :/ However, obviously, the inset needs to be adjust manually now.

@junweimah
Copy link
Author

@electic

Where should I add this code to? Which tabman file?

@junweimah
Copy link
Author

@msaps Did you see my email I sent you yesterday? I recorded some videos for better illustrations

@electic
Copy link

electic commented Mar 22, 2018

I think the issue is that the indenting engine is not accounting for some scenarious. For example in my case, I have:

UIScrollView
-UIView
--UILabbel
--UILable
--UITableView

In this case, I would assume the indenting engine would skip trying to indent the UITableView and indent the parent scrollview or the parent uiview. At least that is what I understand for the code. I have another dashboard in the second UIViewCongtroller where it is:

  • UIScrollView
    --UIView
    ---UIVIew (Graph Component)
    ---UILabel
    ---UITableView
    ---UITableView
    ---UITableView
    ---UIImageView

In this case, I notice it indents the uitabbleview in the middle of the view. So, I think it is something to do with the auto indentation engine and I am not to familiar enough to fix it. For now, to get around this I have disabled the autoindentation and in my constructor just added a property to optionally set padding on the top. Hope it helps.

@junweimah
Copy link
Author

@electic
wow I am too new as an iOS developer to understand all this. Hopefully this is a bug that can, and will be fixed.

By the way you said you changed a file :

    // configure for auto insetting
    //self.automaticallyAdjustsScrollViewInsets = !automaticallyAdjustsChildViewInsets
    autoInsetter.isEnabled = false

Which file is this that you changed?

@electic
Copy link

electic commented Mar 22, 2018

So basically before you set the datasource for Tabman, put in this line:

self.automaticallyAdjustsChildViewInsets = false

That will disable the autoinsetter engine. Then you can manually just move your content down 45 pts.

@junweimah
Copy link
Author

Thanks.

After some effort i got it working, have to manually set top value for child

@msaps
Copy link
Member

msaps commented Mar 22, 2018

@electic @junweimah will take a look at the AutoInsetting logic, and see if I can fix it. Ideally it would handle these sort of scenarios, because it should attempt to find the relative position of the view in the root superview and inset as necessary.

@electic
Copy link

electic commented Mar 22, 2018

@msaps, happy to give you the code or we can do a google hangout as well. Whatever helps debug the issue and saves time :) I use snapkit, so reviewing the code shouldn't be too bad.

@msaps
Copy link
Member

msaps commented Mar 22, 2018

@electic would you be able to see if you can reproduce the issue in this demo project? I've reproduced the kind of layout you are using with a default Tabman setup:

Tabman-TopInsetTest.zip

@electic
Copy link

electic commented Mar 23, 2018

Getting some errors during compiling:

<unknown>:0: error: no such file or directory: '/Users/merrick/Dev/Projects/AutoInsetter/Sources/AutoInsetter/AutoInsetSpec.swift' <unknown>:0: error: no such file or directory: '/Users/merrick/Dev/Projects/AutoInsetter/Sources/AutoInsetter/AutoInsetter.swift' <unknown>:0: error: no such file or directory: '/Users/merrick/Dev/Projects/AutoInsetter/Sources/AutoInsetter/Utilities/UIScrollView+Interaction.swift' <unknown>:0: error: no such file or directory: '/Users/merrick/Dev/Projects/AutoInsetter/Sources/AutoInsetter/Utilities/UIViewController+ScrollViewDetection.swift' Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

I will work on a sample project tonight and attach a zip.

@msaps
Copy link
Member

msaps commented Mar 23, 2018

@electic apologies - was using local pods 😅.

Tabman-TopInsetTest.zip

@electic
Copy link

electic commented Mar 24, 2018

Hi, I use snapkit. But either way, this project has the gap as well.

https://pasteboard.co/Hdma69A.png

To reproduce.

  1. Scroll down about halfway.
  2. Then slowly pan to page two, but not all the way.

Here you will notice that Row 0 suddenly comes down.

  1. Let go to cancel the pan and go back to the first view controller. You will notice Row 0 is still at top of the viewport.
  2. Scroll up to reveal the gap.

@msaps
Copy link
Member

msaps commented Mar 25, 2018

@junweimah @electic - should now be fixed as of AutoInsetter v1.2.3.

The issue was caused by the calculations that decide how much to inset a view by based on its relative position using the incorrect superview in the hierarchy. Let me know how you get on!

@electic
Copy link

electic commented Mar 25, 2018

@msaps It does look like it solves the problem. Going to keep testing it today, will let you know if I find something. Thank you for the great component!

@junweimah
Copy link
Author

Sorry I don't know how merging works. Do I need to remove the pod and pod install again? How do I get the latest code?

@electic
Copy link

electic commented Mar 26, 2018

@junweimah The latest code is in AutoInsetter. The pod has been released. To force it to update, just add the AutoInsetter pod. Here:

pod 'Tabman', '1.6.0' pod 'AutoInsetter', '1.2.3'

@msaps
Copy link
Member

msaps commented Mar 26, 2018

@junweimah @electic it’s probably best to use the constraints of Tabman for versioning.

pod Tabman, '~> 1.6' is sufficient.

To update AutoInsetter, rum pod update AutoInsetter

Sent with GitHawk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants