Closed serhatsezer closed 6 years ago
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?
@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.
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)
@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.
}
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?
Are you still having issues with this?
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:
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),
])
Fixed my issue 👍 , you're the best.
@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.
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.
@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"
@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),
])
My implementation; https://gist.github.com/serhatsezer/6c53e558db0e8880e8594e5a8bf63b16
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 ✌️
New version with both fixes is out now. Let me know if you find any other issues!
@rechsteiner Great thanks. I'll use this framework for future projects. I'm also thinking to contribute to new features. Cheers!
Awesome!
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.`