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

Autolayout issue #115

Closed
serhatsezer opened this issue Jan 16, 2018 · 17 comments
Closed

Autolayout issue #115

serhatsezer opened this issue Jan 16, 2018 · 17 comments

Comments

@serhatsezer
Copy link

I tried to use this library explained in the onboarding page but it gives me a auto-layout warning:

`[LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x608000285f00 V:|-(0)-[UICollectionView:0x7f803388e800] (active, names: '|':Parchment.PagingView:0x7f8032d46f50 )>",
"<NSLayoutConstraint:0x608000286090 UICollectionView:0x7f803388e800.height == 40 (active)>",
"<NSLayoutConstraint:0x608000285690 V:[UICollectionView:0x7f803388e800]-(0)-[UIView:0x7f8032d41970] (active)>",
"<NSLayoutConstraint:0x608000282440 V:[UIView:0x7f8032d41970]-(0)-| (active, names: '|':Parchment.PagingView:0x7f8032d46f50 )>",
"<NSLayoutConstraint:0x600000292ac0 'UIView-Encapsulated-Layout-Height' Parchment.PagingView:0x7f8032d46f50.height == 0 (active)>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x608000285690 V:[UICollectionView:0x7f803388e800]-(0)-[UIView:0x7f8032d41970] (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.`

@rechsteiner
Copy link
Owner

Hi! I'm not able to reproduce the warning you're seeing. Could you provide a bit more details on your setup? Are you running one of the example targets? And which version of iOS and Parchment are you using?

@serhatsezer
Copy link
Author

serhatsezer commented Jan 16, 2018

@rechsteiner Yeah sorry I couldn't give you more detail about the error. But I didn't do any customization or adjustment. I went through readme file. I tried to add both inside custom view and view controller's view but it still gave me the above layout error. I also gave title every controller, I looked all of the example projects. I tried to investigate the error but I couldn't do it because I have little time.

@rechsteiner
Copy link
Owner

Okay, no worries. Have you added any constraints to the PagingViewController so that it's attached to its parent view? I realize now that the README doesn't include anything about setting up the constraints, but if you look at the Example target I'm setting up the constraint using a convenience helper like this:

view.constrainToEdges(pagingViewController.view)

@serhatsezer
Copy link
Author

serhatsezer commented Jan 16, 2018

@rechsteiner Yes I saw your extension but I already add PagingViewController view into my already-constrained view. You can see example below;

let pagerHolderView = UIView()
        view.addSubview(pagerHolderView)
        
        pagerHolderView.snp.makeConstraints { make in
            make.edges.equalTo(self.view).inset(UIEdgeInsetsMake(50, 0, 50, 0)) // 50 for tabbar offset.
        }

@rechsteiner
Copy link
Owner

Ah okay. Are you using the latest version of iOS and Parchment? Is there anything else you’re doing that might be relevant, like subclassing PagingViewController?

@rechsteiner
Copy link
Owner

Are you still having issues with this?

@mikehobi
Copy link

Back again.

I got the same auto-layout warning as @serhatsezer,

When I try to add the view.constrainToEdges(pagingViewController.view) bit, I get this:

screen shot 2018-01-29 at 11 37 03 am

@rechsteiner
Copy link
Owner

Oh, that's because constraintToEdges is not available as part of Parchment. It's only an extension that I made to use in the example targets. You can copy the extension from UIView+constraints.swift in the example target or setup the constraint manually with something like this:

pagingViewController.view.translatesAutoresizingMaskIntoConstraints = false
    
NSLayoutConstraint.activate([
      pagingViewController.view.topAnchor.constraint(equalTo: view.topAnchor),
      pagingViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
      pagingViewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
      pagingViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
])

@mikehobi
Copy link

Fixed my issue 👍 , you're the best.

@serhatsezer
Copy link
Author

serhatsezer commented Jan 30, 2018

@rechsteiner Great. I think this library is pretty neat. Will you fix this framework itself as well? or We can make a pull request for it. People who want to use this library may not see this issue.

@rechsteiner
Copy link
Owner

Thanks! I still haven't been able to reproduce the issue you're seeing, but if you could provide some steps for reproducing it I can fix it right away. And feel free to open a pull-request if you already have a fix for it.

@rechsteiner
Copy link
Owner

@serhatsezer I think I managed to get this fixed now with #125. Can you check out the master branch and see if you're still seeing the layout warnings? 🙏

If you're using CocoaPods you can target the master branch like this:

pod 'Parchment', :git => 'https://github.com/rechsteiner/Parchment.git', :branch => 'master'

Or this if you're using Carthage:

github "rechsteiner/Parchment" "master"

@serhatsezer
Copy link
Author

serhatsezer commented Feb 3, 2018

@rechsteiner Okay it is worked. But there is another problem which I face now. I implemented via pod file which you provided me. Menu items collapsed when I didn't give any title label for FixedPagingViewController. But when I rotate the device in landscape mode it works well. But when I change to top anchor constraint to deprecated one it's working well. I think we should implement this layout code inside FixedPagingViewController this way we can give appropriate layout constraints.

pagingViewController.view.translatesAutoresizingMaskIntoConstraints = false
        
        NSLayoutConstraint.activate([
            pagingViewController.view.topAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor),
            pagingViewController.view.bottomAnchor.constraint(equalTo: bottomLayoutGuide.topAnchor),
            pagingViewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
            pagingViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
            ])

screen shot 2018-02-03 at 17 16 54

screen shot 2018-02-03 at 17 16 54

My implementation;
https://gist.github.com/serhatsezer/6c53e558db0e8880e8594e5a8bf63b16

@rechsteiner
Copy link
Owner

rechsteiner commented Feb 3, 2018

Thanks for the detailed report! Looks like you found a bug that was introduced a while ago (#81). Should be fixed in #127! Releasing a new version now ✌️

@rechsteiner
Copy link
Owner

New version with both fixes is out now. Let me know if you find any other issues!

@serhatsezer
Copy link
Author

@rechsteiner Great thanks. I'll use this framework for future projects. I'm also thinking to contribute to new features. Cheers!

@rechsteiner
Copy link
Owner

Awesome!

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

No branches or pull requests

3 participants