TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Sep 2016 |
SPMSupports SPM | ✗ |
Maintained by Taiki Suzuki.
ManiacDev.com referred.
https://maniacdev.com/2016/09/hoverconversion-a-swift-ui-component-for-navigating-between-multiple-table-views
HoverConversion realized vertical paging with UITableView. UIViewController will be paging when reaching top or bottom of UITableView's contentOffset.
To run the example project, clone the repo, and run pod install
from the Example directory first.
HoverConversion is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "HoverConversion"
If you install from cocoapods, You have to write import HoverConversion
.
Set custom class of UINavigationController
to HCNavigationController
. In addition, set module to HoverConversion
.
And set HCRootViewController
as navigationController
's first viewController.
Set HCNavigationController
as self.window.rootViewController
.
And set HCRootViewController
as navigationController
's first viewController.
If you want to show vertical contents, please use HCPagingViewController
.
let vc = HCPagingViewController(indexPath: indexPath)
vc.dataSource = self
navigationController?.pushViewController(vc, animated: true)
A content included in HCPagingViewController
is HCContentViewController
.
Return HCContentViewController
(or subclass) with this delegate method.
extension ViewController: HCPagingViewControllerDataSource {
func pagingViewController(viewController: HCPagingViewController, viewControllerFor indexPath: NSIndexPath) -> HCContentViewController? {
guard 0 <= indexPath.row && indexPath.row < twitterManager.users.count else { return nil }
let vc = UserTimelineViewController()
vc.user = twitterManager.users[indexPath.row]
return vc
}
}
Return HCNextHeaderView
(or subclass) with this delegate method.
extension ViewController: HCPagingViewControllerDataSource {
func pagingViewController(viewController: HCPagingViewController, nextHeaderViewFor indexPath: NSIndexPath) -> HCNextHeaderView? {
guard 0 <= indexPath.row && indexPath.row < twitterManager.users.count else { return nil }
let view = NextHeaderView()
view.user = twitterManager.users[indexPath.row]
return view
}
}
If you want to load more contents from server and want to stop transitioning, you can use canPaging
in HCContentViewController
.
//Stop transitioning to previous ViewController
canPaging[.prev] = false //Default true
//Stop transitioning to next ViewController
canPaging[.next] = false //Default true
Those OSS are used in sample project!
marty-suzuki, [email protected]
HoverConversion is available under the MIT license. See the LICENSE file for more info.