DataGridView (multicolumn tables) for iOS based on UICollectionView
Branch: master
Clone or download
Latest commit 519d804 Nov 24, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example
Pod/Assets Changed code structure Jul 31, 2015
Source Duplicated IndexPath extension to NSIndexPath Nov 24, 2016
.gitignore Installed pods, added pods to .gitignore Jul 31, 2015
.travis.yml Travis-CI: fixed xcodebuild arguments to include `destination` key Sep 26, 2016
CHANGELOG.md Changelog for v0.3.0 Nov 2, 2016
GlyuckDataGrid.podspec Bump pod version (fixes #5) Nov 2, 2016
LICENSE Initial commit Jul 30, 2015
README.md Trying to fix pod quality badge Jun 8, 2016
_Pods.xcodeproj Initial commit Jul 30, 2015

README.md

GlyuckDataGrid

CI Status Version Quality License Platform

The GlyuckDataGrid is a custom view intended to render multicolumn tables (aka data grids, spreadsheets). Uses UICollectionView with custom UICollectionViewLayout internally.

Screenshot Screenshot

Usage

Minimum working example

import UIKit
import GlyuckDataGrid


class MultiplicationTableViewController: UIViewController, DataGridViewDataSource {
    // You can create view outlet in a Storyboard
    @IBOutlet weak var dataGridView: DataGridView!

    override func viewDidLoad() {
        super.viewDidLoad()

        //// You can also create view manually
        // dataGridView = DataGridView(frame: view.bounds)
        // view.addSubview(dataGridView)
        //// You'll need to setup constraints for just created view
        // dataGridView.setTranslatesAutoresizingMaskIntoConstraints(false)
        // view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-0.0-[dataGridView]-0.0-|", options: nil, metrics: nil, views: ["dataGridView": dataGridView]))
        // view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-0.0-[dataGridView]-0.0-|", options: nil, metrics: nil, views: ["dataGridView": dataGridView]))

        // Don't forget to set dataSource and (optionally) delegate
        dataGridView.dataSource = self
        // dataGridView.delegate = self
    }

    // MARK: - DataGridViewDataSource

    // You'll need to tell number of columns in data grid view
    func numberOfColumnsInDataGridView(dataGridView: DataGridView) -> Int {
        return 9
    }

    // And number of rows
    func numberOfRowsInDataGridView(dataGridView: DataGridView) -> Int {
        return 9
    }

    // Then you'll need to provide titles for columns headers
    func dataGridView(dataGridView: DataGridView, titleForHeaderForRow row: Int) -> String {
        return String(row + 1)
    }

    // And rows headers
    func dataGridView(dataGridView: DataGridView, titleForHeaderForColumn column: Int) -> String {
        return String(column + 1)
    }

    // And for text for content cells
    func dataGridView(dataGridView: DataGridView, textForCellAtIndexPath indexPath: NSIndexPath) -> String {
        return String( (indexPath.dataGridRow + 1) * (indexPath.dataGridColumn + 1) )
    }
}

CocoaPods

To run the example project, run pod try. If you manually clone the repo, and run pod install from the Example directory first.

Installation

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

pod "GlyuckDataGrid"

Author

Vladimir Lyukov, v.lyukov@gmail.com

glyuck.com

License

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