rechsteiner / parchment Goto Github PK
View Code? Open in Web Editor NEWA paging view with a highly customizable menu ✨
License: MIT License
A paging view with a highly customizable menu ✨
License: MIT License
Some strange highlighting in previous and current item when scrolling?
How to remove that ?
Impementation
let vc = FixedPagingViewController(viewControllers: controllers)
vc.font = QTFont.with(14)
vc.backgroundColor = QTColor.darkTurquoise.withNightMode()
vc.indicatorColor = QTColor.sunYellow
vc.selectedTextColor = QTColor.sunYellow
vc.textColor = .white
vc.selectedBackgroundColor = .clear
vc.menuBackgroundColor = .clear
vc.delegate = self
return vc
its possible navigate to next menu tab with button in storyboard?
If you build Parchment (r.0.5.0) with the "leak checker" tool, you can see a memory leak, if I'm not mistaken, the method is:
override open func layoutAttributesForElements (in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {}
lazy var layoutAttributesValues: [UICollectionViewLayoutAttributes] = { [unowned self] in
return Array(self.layoutAttributes.values)
}()
override open func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
var layoutAttributes: [UICollectionViewLayoutAttributes] = layoutAttributesValues
for attributes in layoutAttributes {
if let pagingAttributes = attributes as? PagingCellLayoutAttributes {
pagingAttributes.progress = progressForItem(at: attributes.indexPath)
}
}
let indicatorAttributes = layoutAttributesForDecorationView(
ofKind: PagingIndicatorView.reuseIdentifier,
at: IndexPath(item: 0, section: 0))
let borderAttributes = layoutAttributesForDecorationView(
ofKind: PagingBorderView.reuseIdentifier,
at: IndexPath(item: 1, section: 0))
if let indicatorAttributes = indicatorAttributes {
layoutAttributes.append(indicatorAttributes)
}
if let borderAttributes = borderAttributes {
layoutAttributes.append(borderAttributes)
}
return layoutAttributes
}
"I will be grateful to you ... if you correct this issue as soon as possible.
Thank you
Hello.
I just installed this module via Cocoapods and keep getting No such module 'Parchment'
error, when importing in my ViewController.
I also get 4 errors within the Parchment lib itself:
I haven't made any changes to the files. I've cleaned out and reinstalled my pods as well. Willing to try out the carthage install too, but figured I should file an issue ticket.
I'm using xcode 9.2 and swift 4.
Thanks for this project and your support!
in other words, users can only switch between pagesthrough clicking on the tabs and not being able to switch in any other way (athough only other way I know right now is swiping between the pages themselves)
why i got this error ?
ld: warning: ignoring file /Users/bozo/Desktop/*****/Parchment.framework/Parchment, file was built for x86_64 which is not the architecture being linked (arm64): /Users/bozo/Desktop/*****/Parchment.framework/Parchment ld: '/Users/bozo/Library/Developer/Xcode/DerivedData/*****-dhuanbzszeeilpdafoqmheorglne/Build/Products/Debug-iphoneos/Nimble/Nimble.framework/Nimble' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '/Users/bozo/Library/Developer/Xcode/DerivedData/******-dhuanbzszeeilpdafoqmheorglne/Build/Products/Debug-iphoneos/Nimble/Nimble.framework/Nimble' for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Hello, thanks for creating an awesome library!
In my app, I have a ViewController (let's call: A) that contains FixedPagingViewController that is initialized with 2 viewcontrollers (X & Y). As I just tested, when A is popped off, the function deinit() in X & Y is not called at all. I think if it might lead to a leak memory issue.
Hi,
Is it possible for loading view controllers from the storyboard rather? i.e., each tab would be a viewcontroller from the storyboard. If so, can you provide an example?
Thanks,
Karthik
Is it possible to do an open method:
public func em_pageViewController (_ pageViewController: EMPageViewController, willStartScrollingFrom startingViewController: UIViewController, destinationViewController: UIViewController) {}
I would like to use his heirs class PaguingViivcontroller.
Many thanks.
Two errors in the example project for NavigationBar:
Hey,
I have tried to set up different width for selected cell in IconsExample, wIth selected 60pt and not selected 80pt.
When I slide from controller to controller, relatively fast, pagingViewController on the top occasionally jumps from icon to icon without scrolling animation.
I have added
this
extension ViewController: PagingViewControllerDelegate {
func pagingViewController<T>(_ pagingViewController: PagingViewController<T>, widthForPagingItem pagingItem: T, isSelected: Bool) -> CGFloat {
if isSelected {
return 80
} else {
return 40
}
}
}
and this
override func viewDidLoad() {
...
pagingViewController.delegate = self
}
to the IconsExample ViewController. Did I miss anything? Was that correct?
I am using the following code to try and select a view controller - but its data structure is empty in
let controllers = viewcontrollers(from: pagingItems)
pagingViewController = FixedPagingViewController(viewControllers: controllers, options: CustomOptions())
addChildViewController(pagingViewController!)
viewHolder.addSubview((pagingViewController?.view)!)
viewHolder.constrainToEdges((pagingViewController?.view)!)
// Set our custom data source
pagingViewController!.itemDelegate = self
// Set the current date as the selected paging item
let items = pagingViewController.items
let index = Defaults[.vcIndex]
if index < items.count {
pagingViewController!.selectPagingItem(pagingViewController.items [index])
}
pagingViewController?.didMove(toParentViewController: self)
In PagingViewController.swift, dataStructure is empty.
open func selectPagingItem(_ pagingItem: T, animated: Bool = false) {
if let stateMachine = stateMachine {
if let indexPath = dataStructure.indexPathForPagingItem(pagingItem) {
let direction = dataStructure.directionForIndexPath(indexPath, currentPagingItem: pagingItem)
stateMachine.fire(.select(
pagingItem: pagingItem,
direction: direction,
animated: animated))
}
hi, i have a problem with lib, please help me, how to reload collectionView in pagingView? i try call pagingViewController.collectionView.reloadData() but not work.
hi, is possible modify menu width? for not to occupy the whole screen?
Hi :),
i think i found a bug, example: if u are in the last menu item on the left or right and swipe to left or right, after swipe u cant select menu items
Do you think it's possible to have different width for a selected cell?
And update it (width) dynamically (with animation) moving from current to the next cell.
I was wondering, why does this pod min iOS version is 8.2? I think 8.0 should be fine.
If it is possible, to have the min iOS version set to 8.0 please?
Hi, i just tried to use self size logic in calendar example, I mean use approach in delegate example to have cell size fit to text, but my delegate functions dont fire.
Is it possible to have self size cells for infinite usage?
open class PagingViewController<T: PagingItem>:
is not declaring the optional function
@objc optional func em_pageViewController(_ pageViewController: EMPageViewController, willStartScrollingFrom startingViewController: UIViewController, destinationViewController:UIViewController)
Which require overriding the function in FixedPagingViewController:
open override func em_pageViewController(_ pageViewController: EMPageViewController, didFinishScrollingFrom startingViewController: UIViewController?, destinationViewController: UIViewController, transitionSuccessful: Bool) `
only then will the delegate method willScrollToItem be called.
Added via cocoapods
Version: 0.9.x and 1.0.3
.../Pods/Parchment/Parchment/Classes/PagingOptions.swift:76:50: Type 'UIFont' has no member 'Weight'
In the same time on another pc downloaded this repo and ran examples - they work
Take the storyboard example project, if I want to programmatically select the secondVC, how do I do it?
If I do:
pagingViewController.select(index: 1)
When I run the app, secondVC isn't shown and the top menu still shows the first one and can't navigate anymore. What am I missing?
Sorry if this is a stupid question, I just can't figure it out!
Hello Martin,
Any plans for swift 4.
Even though Swift 3.x and Swift 4 are interchangeable, it would be great if there were a Swift 4 version!
Thank you! 😄
There is a buggy scrolling in pageViewController on iOS 11 / iPhone X. It scrolls in all directions.
Don't know why but this bug is present on all our devices with our project, and only on iPhone X with your example (icon Example)
Apparently, it's linked to this scrollview and to scrollview insets.
In our project, actually by guess, I have solved this problem with this code, though I am not sure if that's the best solution.
scrollView.contentInsetAdjustmentBehavior = .never
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.`
Is there a way to get access to the parent controller from the containerView?
Hello @rechsteiner !
Is there a way to track the index of currently selected viewController, when using FixedPagingViewController
?
How Load viewcontroller at specific index ?
ex: load 3rd viewcontroller in viewdidload
Hi,
In the Delegate Example (cities), I've added in a new controller (HomeViewController) as the initial view controller. From which, I need to navigate to the cities controller (ViewController). Layout as in screen shot
When I wire the "Go to cities" button to the cities controller (ViewController) or to the navigation controller attached to it, the top city selection menu bar (in cities controller) goes missing. But, the left/right swipe works taking to the new city. How do I fix this?
Thanks
I initialized a FixedPagingViewController with two controllers, both with icons. I setup everything inside of viewDidLoad but then I noticed that they are not centered correctly. They only are properly centered after clicking on the other icon or swiping to the other tab. Is this possible a bug? or am I just using it incorrectly
After switching to another tab
Now you can see it is properly centered
Thanks!
Currently, the menu items only have a swipe gesture to switch between pages. It would be nice to be able to scroll freely inside the menu items collection view.
We're currently using EMPageViewController
as a replacement for UIPageViewController
, as it’s more predictable and provides us with much better delegate methods at every step.
Ideally, we would replace this library with our own custom implementation to have even more fined grained control. This would also fix an issue with EMPageViewController
where it occasionally won’t do anything when swiping rapidly between many pages (#26).
Occasionally doesn't recognise swipe when swiping rapidly many controllers from one to another, one direction.
It's just for some parts of a second.
But when you want to swipe rapidly many screens that might be annoying.
Currently FixedPagingViewControllerDelegate does not recognize an aborted scroll. Running the code as noted below increments the index even when a scroll is not completed.
extension UIViewController: FixedPagingViewControllerDelegate{
func fixedPagingViewController(fixedPagingViewController: FixedPagingViewController, willScrollToItem: ViewControllerItem, atIndex index: Int) {
print("about to move to: \(index)")
}
func fixedPagingViewController(fixedPagingViewController: FixedPagingViewController, didScrollToItem: ViewControllerItem, atIndex index: Int) {
Defaults[.vcIndex] = index
print("Moved to: \(index)")
}
}
Suggest something similar to the following changes to FixedPagingViewController that sends destination index only on successful transition
` // MARK: EMPageViewControllerDelegate
open override func em_pageViewController(_ pageViewController: EMPageViewController, didFinishScrollingFrom startingViewController: UIViewController?, destinationViewController: UIViewController, transitionSuccessful: Bool) {
super.em_pageViewController(pageViewController, didFinishScrollingFrom: startingViewController, destinationViewController: destinationViewController, transitionSuccessful: transitionSuccessful)
if let index = items.index(where: { $0.viewController == destinationViewController }) {
if let cIndex = currentIndex {
itemDelegate?.fixedPagingViewController(
fixedPagingViewController: self,
didScrollToItem: items[index],
atIndex: transitionSuccessful ? index : cIndex )
}
}
}
public override func em_pageViewController(_ pageViewController: EMPageViewController, willStartScrollingFrom startingViewController: UIViewController, destinationViewController: UIViewController) {
if let cIndex = items.index(where: { $0.viewController == startingViewController }) {
currentIndex = cIndex
}
if let index = items.index(where: { $0.viewController == destinationViewController }) {
itemDelegate?.fixedPagingViewController(
fixedPagingViewController: self,
willScrollToItem: items[index],
atIndex: index)
}
}`
Right now the menu items are only updated after a transition has completed. Adding a progress on the PagingCell based on how much the content is scrolled would allow us to smoothly transition between size/color etc.
Hello!
We tried but didn't succeed in making the effect when what is vertically scrolled in the view appears underneath the nav. bar in order to have transparency/translucency effect.
Our idea was to make
By view here I mean the any view (tableview, collectionView, ...) that is inserter into the contentView together with the menu (horizontal collection view with icons).
I tried to explain on this picture.
So we need to put the view underneath the nav. bar and the menu. And move it up to the contentView's top margin.
Hi,i want to add menu on navigationbar , how to work it out.
Or Parchment can't do it like that?
I'll be waiting for your reply.
i want the background color to change based on which item is selected
The position of menu items are only updated after a transition has completed. Updating the scroll offset based on how much the content is scrolled would make the transition much smoother. We could still keep the current behaviour as an option.
Is it possible to change the position of the menu to the bottom of the screen?
I'm sorry to bother you yet again but I found this problem.
I had a viewcontroller embed in a uinavigationcontroller and in a uitabbarcontroller.
I compiled the example project you listed and it worked. Then I embed it within a navigation bar but it becomes hidden under the bar. I'm confused because your examples render it correctly.
Also, constrain to edges doesn't work in Swift 4.
Hi, is possible remove click on menu item?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.