Reusable GridView with excellent performance and customization that can be time table, spreadsheet, paging and more.

Overview

GridView

Build Status Carthage compatible Version License Platform

GridView can tile the view while reusing it. It has an API like UIKit that works fast. Even when device rotates it smoothly relayout.

timetable timetable

Appetize's Demo

You Can

  • Scroll like paging
  • Scroll infinitely
  • Scale the view
  • Call API like the UITableView

Requirements

  • Swift 5.0
  • iOS 9.0 or later

How to Install

CocoaPods

Add the following to your Podfile:

pod "G3GridView"

⚠️ WARNING : If you want to install from CocoaPods, must add G3GridView to Podfile because there is a GridView different from this GridView.

Carthage

Add the following to your Cartfile:

github "KyoheiG3/GridView"

Over View

GridView can scroll in any direction while reusing Cell like UITableView. Also it is based UIScrollView and paging and scaling are possible. If necessary, it is possible to repeat the left and right scroll infinitely.

GridView is one UIScrollView, but the range which Cell is viewed depends on Superview. Cell reuse is also done within the range which Superview is viewed, so its size is very important.

On the other hand, scaling and paging depend to position and size of GridView. 'bounds' is important for paging, 'frame' is important in scaling. The same is true for offset of content.

The following image is a visual explanation of the view hierarchy.

Hierarchy

You can use it like the UITableView APIs. However, there is concept of Column. The following functions are delegate APIs of 'GridView'.

func gridView(_ gridView: GridView, numberOfRowsInColumn column: Int) -> Int
func gridView(_ gridView: GridView, cellForRowAt indexPath: IndexPath) -> GridViewCell

@objc optional func numberOfColumns(in gridView: GridView) -> Int

You can see that must return the count.

Examples

This project is including two examples that is timetable and paging. Those can change on Interface Builder for following:

Example

Try the two examples.

timetable paging
timetable paging

Usage

Variables

Infinite Loop

A horizontal loop is possible.

open var isInfinitable: Bool
  • Default is true.
  • Set false if you don't need to loop of view.

loop

gridView.isInfinitable = true

Scaling

Content is done relayout rather than scaling like 'UIScrollView'.

open var minimumScale: Scale
open var maximumScale: Scale
  • Default for x and y are 1.
  • Set the vertical and horizontal scales.
public var currentScale: Scale { get }
  • Get current vertical and horizontal scales.

scaling

gridView.minimumScale = Scale(x: 0.5, y: 0.5)
gridView.maximumScale = Scale(x: 1.5, y: 1.5)

Fill for Cell

It is possible to decide the placement of Cell at relayout.

open var layoutWithoutFillForCell: Bool
  • Default is false.
  • Set true if need to improved view layout performance.
false true
false true
gridView.layoutWithoutFillForCell = true

Content Offset

If isInfinitable is true, contentOffset depends on the content size including size to loop. It is possible to take content offset that actually visible.

open var actualContentOffset: CGPoint { get }

Delegate

Set the delegate destination. This delegate property is UIScrollViewDelegate but, actually set the GridViewDelegate.

weak open var dataSource: GridViewDataSource?
open var delegate: UIScrollViewDelegate?

Functions

State

Get the view state.

public func visibleCells<T>() -> [T]
public func cellForRow(at indexPath: IndexPath) -> GridViewCell?
public func rectForRow(at indexPath: IndexPath) -> CGRect
public func indexPathsForSelectedRows() -> [IndexPath]
public func indexPathForRow(at position: CGPoint) -> IndexPath

Operation

Operate the view.

public func contentScale(_ scale: CGFloat)
public func reloadData()
public func invalidateContentSize()
public func invalidateLayout(horizontally: Bool = default)
public func deselectRow(at indexPath: IndexPath)
override open func setContentOffset(_ contentOffset: CGPoint, animated: Bool)
public func scrollToRow(at indexPath: IndexPath, at scrollPosition: GridViewScrollPosition = default, animated: Bool = default)

LICENSE

Under the MIT license. See LICENSE file for details.

Comments
  • Initial tvOS Support 📺

    Initial tvOS Support 📺

    🎉 gridview-tvos

    This is kind of beta implementation.

    We still need to ..

    • improve infinite loading timing
    • provide delegate method like UICollectionView's collectionView(:didUpdateFocusInContext:withAnimationCoordinator:) (not sure if possible🤔)
    opened by toshi0383 7
  • Upgrade Tests to Swift 5

    Upgrade Tests to Swift 5

    Hi, Author.

    I upgraded Tests to Swift 5 to conform with swift version of production code. But, I cannot confirm TravisCI. Please check test success or failure in ci.

    opened by Nonchalant 2
  • Foward delegete method invocations

    Foward delegete method invocations

    GridView forwards responds(to:) to originDelegate.

    https://github.com/KyoheiG3/GridView/blob/20dfa888af11f79a622e2b647a45b329fe7d7b48/GridView/GridView.swift#L120-L122

    If originDelegate implements a delegate method, however, the method invocation is not forwarded to the originDelegate and results in an exception:

    -[G3GridView.GridView scrollViewWillBeginDragging:]: unrecognized selector sent to instance 0x7f811c15f800
    

    This PR addresses this problem by forwarding the actual invocation to the delegate.

    opened by akkyie 1
  • Support Code Layout

    Support Code Layout

    Hi, Author.

    Currently Initializer of GridView supports only Interface Builder. https://github.com/KyoheiG3/GridView/blob/4ddc758d2828150773e2c7fc41402aa800d7cf04/GridView/GridView.swift#L102-L118 https://github.com/KyoheiG3/GridView/blob/4ddc758d2828150773e2c7fc41402aa800d7cf04/GridViewExample/GridViewExample/TimeTableViewController.swift#L23-L25

    But, I want to initalize GridView in code. I fix access modifier to public to enable to access from outside of module.

    class ViewController: UIViewController {
        private weak var gridView = GridView(frame: .zero)
    }
    
    opened by Nonchalant 1
  • Can GridView be used as a EPG viewer?

    Can GridView be used as a EPG viewer?

    Dear friend: First of all, my congratulations for the excelent work. I wish to ask a question: Can GridView be used to show an EPG (Electronic Program Viewer)? The date/time should be in top and the channel names in left 9using some kind of custom cell layout). Is this possible?

    Thanks for your help.

    opened by ssaguiar 1
  • Ability to reload datasource without calling reloadData

    Ability to reload datasource without calling reloadData

    Hello! Thanks for nice implementation of reusable collection on pure scrollview. Now I'm using gridview for unlimited horizontal feed of cards. The question is: How can I update datasource without call reloadData? For better UX I need to update datasource without reloading current visible cells. If you have any suggestions how to do it, please answer here:)

    opened by pokhachevskiy 1
  • Please Help !

    Please Help !

    Dear author, My project USES your library But I find that the Reload of TableView causes the screen to be delayed MainQueue does too much at the same time, right? And this condition is in Sample, I wonder if you can optimize it? I can pay for this optimization! Or Donate!

    opened by League2EB 4
  • Can not run project

    Can not run project

    Dear admin,

    I can not run this project, error occurs when executing this line timeTableView.register(TimeTableGridViewCell.nib, forCellWithReuseIdentifier: "TimeTableGridViewCell") channelListView.register(ChannelListGridViewCell.nib, forCellWithReuseIdentifier: "ChannelListGridViewCell") dateTimeView.register(DateTimeGridViewCell.nib, forCellWithReuseIdentifier: "DateTimeGridViewCell")

    Could you please help me resolve this issues

    opened by bhnam123 0
  • Value of type error

    Value of type error

    Hi. I am trying to run GridViewExample. When I try to run it, swift compile error appears in the function visibleCells it says has no member 'compactMap'. I am using Xcode 9.2.

    public func visibleCells() -> [T] { return currentInfo.visibleObject().values.compactMap { $0.view as? T } }

    Thank you. screen shot 2018-11-15 at 11 24 18 am

    opened by agent134ssa 1
Owner
Kyohei Ito
Kyohei Ito
A Swift utility to make updating table views/collection views trivially easy and reliable.

ArrayDiff An efficient Swift utility to compute the difference between two arrays. Get the removedIndexes and insertedIndexes and pass them directly a

Adlai Holler 100 Jun 5, 2022
Simple static table views for iOS in Swift.

Simple static table views for iOS in Swift. Static's goal is to separate model data from presentation. Rows and Sections are your “view models” for yo

Venmo 1.3k Jan 5, 2023
An extension that simplifies the work with Swift AutoLayout by writing cleaner, more natural and easy-reading code.

Installation For now you're able to clone repo in your project or download ZIP folder manually. git clone https://github.com/votehserxam/AutoLayout.gi

Max 3 Nov 8, 2022
Customise sheets on iOS, bottom sheets, custom detents and more..

Sheetster A custom sheet creator library for iOS Devices Features Extends UISheetPresentationController Objective C Private API Custom Detent Setter G

Admir Šaheta 3 Nov 27, 2022
Allows users to pull in new song releases from their favorite artists and provides users with important metrics like their top tracks, top artists, and recently played tracks, queryable by time range.

Spotify Radar Spotify Radar is an iOS application that allows users to pull in new song releases from their favorite artists and provides users with i

Kevin Li 630 Dec 13, 2022
FreeOTP is a two-factor authentication application for systems utilizing one-time password protocols

FreeOTP FreeOTP is a two-factor authentication application for systems utilizing one-time password protocols. Tokens can be added easily by scanning a

FreeOTP 551 Dec 28, 2022
Better time picker for iOS.

TimePicker Better TimePicker for iOS Requirements Swift 5.0 iOS 10.0+ Xcode 10.2+ Installation The easiest way is through CocoaPods. Simply add the de

Oleh 14 Oct 21, 2022
App desenvolvido do zero em Swift pelo time iOS na formação da Digital House

App desenvolvido do zero em Swift pelo time iOS na formação da Digital House. O App tem por objetivo mostrar o filme da API que deu match de acordo com a escolha do usuário após clicar no botão Roletar. Foi usado o padrão de projeto MVVM.

Raul F. Andrade 0 Nov 21, 2022
Real-time communication application form Google Jacquard tag to macOS

Jacquard RTC Real-time communication application form Google Jacquard tag to macOS Abstract Want to use your Google Jacquard equipped product with you

Phumrapee Limpianchop 4 Nov 28, 2022
MisterFusion is Swift DSL for AutoLayout. It is the extremely clear, but concise syntax, in addition, can be used in both Swift and Objective-C. Support Safe Area and Size Class.

MisterFusion MisterFusion makes more easier to use AutoLayout in Swift & Objective-C code. Features Simple And Concise Syntax Use in Swift and Objecti

Taiki Suzuki 316 Nov 17, 2022
Powerful autolayout framework, that can manage UIView(NSView), CALayer and not rendered views. Not Apple Autolayout wrapper. Provides placeholders. Linux support.

CGLayout Powerful autolayout framework, that can manage UIView(NSView), CALayer and not rendered views. Has cross-hierarchy coordinate space. Implemen

Koryttsev Denis 45 Jun 28, 2022
Server Driven UI can enable faster iterations and allowing apps to instantly update on multiple platforms.

Pets App Server Driven UI can enable faster iterations and allowing apps to instantly update on multiple platforms Steps to run Pets-Web: Download or

Metin Atalay 0 Jun 11, 2022
📱AutoLayout can be set differently for each device

DeviceLayout DeviceLayout is a Swift framework that lets you set Auto Layout constraints's differently for each device Using only IBInspector of Xcode

Cruz 171 Oct 11, 2022
Using the UIKitChain framework, You can create a UIKit component in one line of code.

Using the UIKitChain framework, You can create a UIKit component in one line of code. Installation CocoaPods CocoaPods is a dependency manager for Coc

Malith Nadeeshan 1 Sep 1, 2022
SimpleMagnifyingView can be used as a magnifier as the one iOS providing 🔍. SwiftUI supported!

SimpleMagnifyingView SimpleMagnifyingView is a SwiftUI view which can create a magnifier 中文说明 How it works Example MagnifierView(isMagnifying: $isMagn

Tomortec 8 Nov 24, 2022
Library that makes it easy to create multiple environments within a single app. You can switch environments without deleting the application.

AppContainer Library that makes it easy to create multiple environments within a single app. You can switch environments without deleting the applicat

null 8 Dec 15, 2022
✂ Easy to use and flexible library for manually laying out views and layers for iOS and tvOS. Supports AsyncDisplayKit.

ManualLayout Table of Contents Installation Usage API Cheat Sheet Installation Carthage Add the following line to your Cartfile. github "isair/ManualL

Baris Sencan 280 Sep 29, 2022
CompositionalLayoutDSL, library to simplify the creation of UICollectionViewCompositionalLayout. It wraps the UIKit API and makes the code shorter and easier to read.

CompositionalLayoutDSL CompositionalLayoutDSL is a Swift library. It makes easier to create compositional layout for collection view. Requirements Doc

FABERNOVEL 44 Dec 27, 2022
Harness the power of AutoLayout NSLayoutConstraints with a simplified, chainable and expressive syntax. Supports iOS and OSX Auto Layout

Masonry Masonry is still actively maintained, we are committed to fixing bugs and merging good quality PRs from the wider community. However if you're

null 18k Jan 5, 2023