Latest 0.1.1
Homepage https://github.com/marty-suzuki/SplittableViewKit
License MIT
Platforms ios 9.0
Authors

Language
Carthage compatible
Version
License
Platform

A cell of IndexPath(row: 0, section: 0) in UITableView is automatically moved to left view when device rotated.

SplittableViewKit

Usage

Please initialize SplittableTableView with initializer or Interface Builder.
SplittableTableView.rightView is UITableView.
Do not set delegate or dataSource directly to SplittableTableView.rightView.
You must use SplittableTableView.delgate or SplittableTableView.dataSource.

let splittableTableView: SplittableTableView

splittableTableView.delegate = self
splittableTableView.dataSource = self
splittableTableView.rightView.register(UINib(nibName: "ThumbnailViewCell", bundle: nil),
                                       forCellReuseIdentifier: "ThumbnailViewCell")

SplittableViewKit is almost same as UITableView interface because SplittableTableViewDataSource adopted UITableViewDataSource and SplittableTableViewDelegate adopted UITableViewDelegate.
func splittableContainerViewFor(topView: UIView, layoutType: LayoutType) -> UIView is only one difference.
You should return a UIView that layouted top view. Layout patterns are LayoutType.left and LayoutType.fixedTop.

extension ViewController: SplittableTableViewDataSource {
    func splittableContainerViewFor(topView: UIView, layoutType: LayoutType) -> UIView {
        let view = UIView(frame: .zero)
        topView.translatesAutoresizingMaskIntoConstraints = false
        view.addSubview(topView)
        if layoutType == .left {
            NSLayoutConstraint.activate([
                view.leadingAnchor.constraint(equalTo: topView.leadingAnchor, constant: 0),
                view.trailingAnchor.constraint(equalTo: topView.trailingAnchor, constant: 0),
                view.centerYAnchor.constraint(equalTo: topView.centerYAnchor, constant: 0)
            ])
        } else {
            NSLayoutConstraint.activate([
                view.safeAreaLayoutGuide.topAnchor.constraint(equalTo: topView.topAnchor, constant: 0),
                view.leftAnchor.constraint(equalTo: topView.leftAnchor, constant: 0),
                view.rightAnchor.constraint(equalTo: topView.rightAnchor, constant: 0),
                view.bottomAnchor.constraint(equalTo: topView.bottomAnchor, constant: 0)
            ])
        }
        return view
    }
}

You can change fixed top or not with SplittableTableView.isFixedTop.

splittableTableView.isFixedTop = true
left fixedTop
SplittableViewKit SplittableViewKit

You can change ratio of leftView and rightView with SplittableTableView.ratio.

splittableTableView.ratio = .init(left: 1, right: 2)
left: 1, right: 1 left: 2, right: 1
SplittableViewKit SplittableViewKit

Example

To run the example project, clone the repo, and run pod install from the SplittableViewKitExample directory first.

Requirements

  • iOS 9 or greater
  • Swift 4 or greater

Installation

Carthage

If you’re using Carthage, simply add SplittableViewKit to your Cartfile:

github "marty-suzuki/SplittableViewKit"

CocoaPods

SplittableViewKit is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'SplittableViewKit'

Author

marty-suzuki, [email protected]

License

SplittableViewKit is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SplittableViewKit",
    "version": "0.1.1",
    "summary": "UITableView based splittable view.",
    "homepage": "https://github.com/marty-suzuki/SplittableViewKit",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "marty-suzuki": "[email protected]"
    },
    "source": {
        "git": "https://github.com/marty-suzuki/SplittableViewKit.git",
        "tag": "0.1.1"
    },
    "social_media_url": "https://twitter.com/marty_suzuki",
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "Sources/**/*.{swift,h,m}",
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This