Git Product home page Git Product logo

bannzai / spreadsheetview Goto Github PK

View Code? Open in Web Editor NEW
3.5K 81.0 452.0 7.28 MB

Full configurable spreadsheet view user interfaces for iOS applications. With this framework, you can easily create complex layouts like schedule, gantt chart or timetable as if you are using Excel.

License: MIT License

Swift 43.00% Objective-C 0.05% Ruby 0.74% HTML 52.01% CSS 3.67% JavaScript 0.46% Shell 0.06%
spreadsheet timetable grid-layout gantt-chart schedule ios

spreadsheetview's Introduction

Build Status Codecov Pods Version Platforms Carthage Compatible


Full configurable spreadsheet view user interfaces for iOS applications. With this framework, you can easily create complex layouts like schedule, Gantt chart, timetable as if you are using Excel.

 
 

Features

  • Fixed column and row headers
  • Merge cells
  • Circular infinite scrolling automatically
  • Customize gridlines and borders for each cell
  • Customize inter cell spacing vertically and horizontally
  • Fast scrolling, memory efficient
  • UICollectionView like API
  • Well unit tested
Find the above displayed examples in the Examples folder.

Requirements

SpreadsheetView is written in Swift 5. Compatible with iOS 9.0+

Installation

CocoaPods

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

pod 'SpreadsheetView'

Carthage

For Carthage, add the following to your Cartfile:

github "kishikawakatsumi/SpreadsheetView"

Getting Started

The minimum requirement is connecting a data source to return the number of columns/rows, and each column width/row height.

import UIKit
import SpreadsheetView

class ViewController: UIViewController, SpreadsheetViewDataSource {
    @IBOutlet weak var spreadsheetView: SpreadsheetView!

    override func viewDidLoad() {
        super.viewDidLoad()
        spreadsheetView.dataSource = self
    }

    func numberOfColumns(in spreadsheetView: SpreadsheetView) -> Int {
        return 200
    }

    func numberOfRows(in spreadsheetView: SpreadsheetView) -> Int {
        return 400
    }

    func spreadsheetView(_ spreadsheetView: SpreadsheetView, widthForColumn column: Int) -> CGFloat {
      return 80
    }

    func spreadsheetView(_ spreadsheetView: SpreadsheetView, heightForRow row: Int) -> CGFloat {
      return 40
    }
}

Usage

Freeze column and row headers

Freezing a column or row behaves as a fixed column/row header.

Column Header

func frozenColumns(in spreadsheetView: SpreadsheetView) -> Int {
    return 2
}

Row Header

func frozenRows(in spreadsheetView: SpreadsheetView) -> Int {
    return 2
}

both

func frozenColumns(in spreadsheetView: SpreadsheetView) -> Int {
    return 2
}

func frozenRows(in spreadsheetView: SpreadsheetView) -> Int {
    return 2
}

Merge cells

Multiple cells can be merged and then they are treated as one cell. It is used for grouping cells.

func mergedCells(in spreadsheetView: SpreadsheetView) -> [CellRange] {
    return [CellRange(from: (row: 1, column: 1), to: (row: 3, column: 2)),
            CellRange(from: (row: 3, column: 3), to: (row: 8, column: 3)),
            CellRange(from: (row: 4, column: 0), to: (row: 7, column: 2)),
            CellRange(from: (row: 2, column: 4), to: (row: 5, column: 8)),
            CellRange(from: (row: 9, column: 0), to: (row: 10, column: 5)),
            CellRange(from: (row: 11, column: 2), to: (row: 12, column: 4))]
}

Circular Scrolling

Your table acquires infinite scroll just set circularScrolling property.

Enable horizontal circular scrolling

spreadsheetView.circularScrolling = CircularScrolling.Configuration.horizontally

Enable vertical circular scrolling

spreadsheetView.circularScrolling = CircularScrolling.Configuration.vertically

Both

spreadsheetView.circularScrolling = CircularScrolling.Configuration.both

If circular scrolling is enabled, you can set additional parameters that the option not to repeat column/row header and to extend column/row header to the left/top edges. CircularScrolling.Configuration is a builder pattern, can easily select the appropriate combination by chaining properties.

e.g.

spreadsheetView.circularScrolling = 
    CircularScrolling.Configuration.horizontally.columnHeaderNotRepeated
spreadsheetView.circularScrolling = 
    CircularScrolling.Configuration.both.columnHeaderStartsFirstRow

Customize gridlines, borders and cell spacing

You can customize the appearance of grid lines and borders of the cell. You can specify whether a cell has a grid line or border. Grid lines and borders can be displayed on the left, right, top, or bottom, or around all four sides of the cell.

The difference between gridlines and borders is that the gridlines are drawn at the center of the inter-cell spacing, but the borders are drawn to fit around the cell.

Cell spacing

spreadsheetView.intercellSpacing = CGSize(width: 1, height: 1)

Gridlines

SpreadsheetView's gridStyle property is applied to the entire table.

spreadsheetView.gridStyle = .solid(width: 1, color: .lightGray)

You can set different gridStyle for each cell and each side of the cell. If you set cell's gridStyle property to default, SpreadsheetView's gridStyle property will be applied. Specify none means the grid will not be drawn.

cell.gridlines.top = .solid(width: 1, color: .blue)
cell.gridlines.left = .solid(width: 1, color: .blue)
cell.gridlines.bottom = .none
cell.gridlines.right = .none

Border

You can set different borderStyle for each cell as well.

cell.borders.top = .solid(width: 1, color: .red)
cell.borders.left = .solid(width: 1, color: .red)
cell.borders.bottom = .solid(width: 1, color: .red)
cell.borders.right = .solid(width: 1, color: .red)

Author

Kishikawa Katsumi, [email protected]

License

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

spreadsheetview's People

Contributors

bannzai avatar kishikawakatsumi avatar leomehlig avatar marcuswu0814 avatar muescha avatar wowlocal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spreadsheetview's Issues

Content offset doesn't work

Hi, I'm creating a spreadsheet view that gets its data periodically refreshed. Whenever I reload data, I want to remember where the user scrolled to. However, the view will always reload to the beginning of the scroll view. Here's my code:

override func willMove(toSuperview newSuperview: UIView?) {
        super.willMove(toSuperview: newSuperview)
        timer = Timer.scheduledTimer(timeInterval: 2.0, target: self, selector: #selector(updateContents), userInfo: nil, repeats: true)
        timer.fire()
    }


func updateContents() {
        let contentOffset = spreadsheetView.contentOffset
        print(contentOffset)
        spreadsheetView.reloadData()
        spreadsheetView.contentOffset = contentOffset
}

I'm printing out the contentOffset values and they seem to be calculated correctly.
screen shot 2017-06-30 at 11 16 25 am

Do you know what the issue might be? Thanks!

Colour Attributes don't work for columns

@kishikawakatsumi Hello..!! I am working on Schedule example.

Expected Behaviour

Columns should have alternate darkGray and lightGray colour.

Actual Behaviour

Initially when the app launches, the background colour for respective cells is filled in empty cells. Then upon scrolling horizontally, some cells are filled with background colour and some are not. Also the colour gets transferred to other column. Also can you please add "Cell" UI part in the storyBoard. It is very difficult to understand the UI part from the code. Please Help!!

Specifications

  • Xcode version: 8.2.1
  • iOS version:
  • Dependency manager + version:
    initial
    randomcell
    coltrans

Sticky Rows and Columns can bounce

Expected Behavior

  1. Sticky Rows and Columns stick tightly on the borders
  2. vertical indicator would shake when dragging none-vertically and none-horizontally to make the header away from the top then release your hand

Actual Behavior

Sticky Rows and Columns can bounce

Steps to Reproduce the Problem

Specifications

  • Xcode version: Xcode9-beta4
  • iOS version: iOS11-beta4
  • Dependency manager + version: ?

How to fit column width to cell text length?

Thanks for a good looking spreadsheetview, I am interested in the timetable in particular.

I have two questions, I looked at the code but didn't find an immediate way to do the below so I'll just ask:

  1. Column widths are specified by the delegate - can this be handled by autolayout instead, someway?

  2. How would I turn off the titles (channel names)? I'd like to not show that top row at all.

`reloadData()` doesn't reflect the latest data source

Hi Kishikawa,

Thanks for a really excellent spreadsheet view, which I have incorporated into my app.

One problem. I change some settings and try to refresh the spreadsheetView with the usual:

spreadsheetView.reloadData() or
spreadsheetView.setNeedsDisplay()

But this has no effect on

func spreadsheetView(_ spreadsheetView: SpreadsheetView, cellForItemAt indexPath: IndexPath) -> Cell?

Any suggestions?

Thanks

Roger

IntrinsicContentSize

Hello!

I've got a question for you, and it revolves around the intrinsic content size. I have a need to build a component around your spreadsheet view, potentially stacking multiple spreadsheets within a single scroll view. To do this, it's important that we have support for intrinsicContentSize from the SpreadsheetView, and I'd like to know what you think the best way to approach this would be.

I wrote an extension that add this functionality in, but requires the SpreadsheetView, and a bit else in the framework, to be open instead of public. I know from a previous Issue that you'll add that in after you hit 1.0, so that's not something I'll ask about right now. I'd like to know if it makes sense to give some thought to this, or if I can make an addition akin to what I've written here and submit a pull request.

class HeightExpandableSpreadsheetView : SpreadsheetView {
	
	override var intrinsicContentSize : CGSize {
		
		return CGSize(width: frame.size.width, height: tableView.contentSize.height)
	}
	
	override func setNeedsLayout() {
		super.setNeedsLayout()
		invalidateIntrinsicContentSize()
	}
	
	override func refreshData() {
		super.refreshData()
		invalidateIntrinsicContentSize()
	}
}

I think, ultimately, it would make sense to make this a default behavior (well, for width and height, instead of just height as in my example), since this can all be ignored by setting size constraints anyway.

Can't use pod to get SpreadsheetView

When I add pod 'SpreadsheetView' into my Podfile and run pod install, it show me "[!] Unable to find a specification for SpreadsheetView"
And I run pod search, it also couldn't find it.

Please check this, thx.

Swift 4

Hi!
I'm using xcode-beta-9 and getting few errors? Any plan to add the code for swift 4?

Thx! :)

Crash in iOS 11 if binary built with base SDK iOS 10

Expected Behavior

No crash

Actual Behavior

Crash in SpreadsheetView+Layout.resetScrollViewFrame()

Steps to Reproduce the Problem

  1. Archive project using Xcode 8.3 and test the build using TestFlight or any other distribution method
  2. Run the build in iOS 11 (DP 6-10)
  3. Open screen with SpreadsheetView and it will crash immediately with error logs:
Crashed: com.apple.main-thread
0  libswiftCore.dylib             0x10634f740 specialized _assertionFailure(StaticString, String, file : StaticString, line : UInt, flags : UInt32) -> Never (__hidden#17348_:134)
1  SpreadsheetView                0x105b1f330 @objc SpreadsheetView.resetScrollViewFrame() -> () (SpreadsheetView+Layout.swift)
2  SpreadsheetView                0x105b1f34c @objc SpreadsheetView.resetScrollViewFrame() -> () (SpreadsheetView+Layout.swift)
3  SpreadsheetView                0x105b298b8 SpreadsheetView.reloadData() -> () (SpreadsheetView.swift:442)
4  SpreadsheetView                0x105b1df24 SpreadsheetView.layoutSubviews() -> () (SpreadsheetView+Layout.swift:457)
5  SpreadsheetView                0x105b1e3c4 @objc SpreadsheetView.layoutSubviews() -> () (SpreadsheetView+Layout.swift)
6  UIKit                          0x18a8c8d70 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1256
7  QuartzCore                     0x1854fbcc8 -[CALayer layoutSublayers] + 184
8  QuartzCore                     0x1854ffda8 CA::Layer::layout_if_needed(CA::Transaction*) + 332
9  QuartzCore                     0x18546fb50 CA::Context::commit_transaction(CA::Transaction*) + 336
10 QuartzCore                     0x185495f6c CA::Transaction::commit() + 540
11 QuartzCore                     0x185496dac CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 92
12 CoreFoundation                 0x1814df8b8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
13 CoreFoundation                 0x1814dd270 __CFRunLoopDoObservers + 412
14 CoreFoundation                 0x1814dd82c __CFRunLoopRun + 1292
15 CoreFoundation                 0x1813fe2d8 CFRunLoopRunSpecific + 436
16 GraphicsServices               0x183283f84 GSEventRunModal + 100
17 UIKit                          0x18a92f5e0 UIApplicationMain + 208
18 Invoice2go Staging             0x10413fb08 main (L10n+Invoice.swift:16)
19 libdyld.dylib                  0x180f2256c start + 4

Specifications

  • Xcode version: 8.3
  • iOS version: 11
  • Dependency manager + version: Cocoapods

Seems like the crash coming from runtime checker in:

if #available(iOS 11.0, *) {
    #if swift(>=3.2)
        contentInset = rootView.adjustedContentInset
    #else
    fatalError("unreachable code")
    #endif
} else {
    contentInset = rootView.contentInset
}

Debug/archive the same code using Xcode 9 (DP 6) seems to fix the problem, but it means we cannot use SpreadsheetView v0.8.x in production app. Right now the solution is to revert our SpreadsheetView to v0.8.0.

Swift Package Manager?

  1. Is it possible that you can restructure your project files so that is it compatible with Swift Package Manager?

  2. Also, one question.
    I maintain a calendar project and I was thinking of developing a Calendar Schedule Week view, but I stumbled across this excellent framework and was wondering if doing that library would be unnecessary.
    Can someone create a Calendar WeekView using this framework?
    Some thing like this?

Except with many functions etc that relates to dates/time rather than just working with a spreadsheet?

screen shot 2017-06-02 at 8 19 06 am

If you do not have date/time related functions etc, then maybe I can use this framework as a dependency, and then wrap time/date functions around it.

reloadData() doesn't reset cells

Hello!
First of all, thank you for this extremely useful library.
I'm having a data update problem.

What I basically need to do is to show a timetable of events which can vary from day to day. I want to refresh all the contents in the spreadsheet according to the day I select so that only the events in that day are shown.

The problem I am experiencing is that by using "reloadData()" the contents are indeed refreshed, but the spreadsheet is not first reset to the initial state before doing it. What happens is that if I change the day, I can see the new, correct events AND the events of the day I had selected before, and if some of the events happen to ovelap (because the events can take more than one cell, like in the "Timetable" example, which I'm using as a base for what I'm doing), the application crashes.

I don't think I'm missing anything, I'm doing exactly the same things I use to do when handling tableviews, so I thought it might be a bug.

Thanks for any help you'll be able to give me.

Problem when installing with CocoaPods

When I try to install with Cocoa Pods I'm getting the "Convert to Current Swift Syntax?" dialog as soon as I open the workspace telling me that :

"The target “SpreadsheetView” contains source code developed with an earlier version of Swift.
Choose “Convert” to update the source code in this target to Swift 3."

If I choose "Convert" I get loads of syntax errors. If I choose "Later" I'm told that its unsupported syntax

Xcode 8.3.3

xCode 9 Beta - Swift 3.2/4 Compatibility With Schedule Example

Tested the Schedule Example out on xCode 9 with the Swift 4 compiler as Swift version 3.2 in the build settings and it would compile but when trying to open in the emulator it would crash. All other examples worked fine.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SpreadsheetView.SpreadsheetView refreshControl]: unrecognized selector sent to instance 0x7fdc6f72c2a0'

error

SIGABRT on simulator when showing a SpreadsheetView

Expected Behavior

Show the view controller containing a spreadsheet (in my case, you access the controllers via a tab bar)

Actual Behavior

On the simulator, I get a generic SIGABRT error whenever I try to show a view controller containing a spreadsheet.

IT STILL WORKS ON AN ACTUAL DEVICE, the problem seems to only affect the simulator.

Specifications

  • Xcode version: 9
  • iOS version: 10 on device, 11 on simulator
  • Dependency manager + version: CocoaPods, 0.7.2 in the Sw3 project, 0.8.4 in the Sw4 one.

Question: Cells appearing from bottom

Does this allow cells to appear from bottom and up?
Like, if you only have one cell, it would appear at bottom of the bounds of the SpreadsheetView. If you have two cells, the new cell (with row index 1) pushes the first cell 0 "up" one step.

+-----+
|     |
|     |
|     |
|row 0|
+-----+

+-----+
|     |
|     |
|row 0|
|row 1|
+-----+

+-----+
|     |
|row 0|
|row 1|
|row 2|
+-----+

I guess with a Spreadsheet view it might come down to implementation details, but I'm just checking if this is something that would be easily possible with the current SpreadsheetView framework.

UI misplaced when reloadData() with frozenColumns changed

I have 4 buttons, and when I click one, I'll reloadData...
First I set frozenColumns to be 4, frozenRows to be 1, everything work fine, but when I click one button and reloadData(), set frozenColumns to be 0, the UI misplaced. The later header and data resource are less than the former one.
img_0166

Why show this? expect your answer, thx.

ScrollToItem moves rows to the bottom

Hello, I seem to have an issue that I don't know how to solve.

I have a spreadsheet with a variable number of rows, and I noticed that if I use the ScrollToItem command when the height of all rows is lower than the SpreadsheetView's height, all the rows are moved to the bottom side of the view. This is not the kind of behaviour I'm looking for, as I want that the rows remain on the upper side exactly as they are created.

Is there a way to solve this, some kind of configuration I've missed, or is it a bug?

Thank you for helping me out.

Support Objective-C only project

Hello,

first of all, many thanks for this awesome library.

I am trying to use is in my Objective C project, but it seems it is not posible at all for now... the protocols (data source and delegate) are not available from the -Swift.h file, so there is no chance to implement them. Are you planning to make them available soon?

Thanks!

Scrollable content size looks like calculated for the first time only

Expected Behavior

Scrollable content size should be recalculated every time after reloadData method is called

Actual Behavior

If data source return 0 columns in numberOfColumns method for the first time then later you cannot scroll SpreadsheetView horizontally when data source return many columns in numberOfColumns method

Also if data source return many columns in numberOfColumns method for the first time then later you can scroll SpreadsheetView horizontally for large distance when data source return 1-2 columns and SpreadsheetView should not be scrollable

Steps to Reproduce the Problem

  1. Make simple test app
  2. Let data source return 100 columns in numberOfColumns method for the first time. Be sure that your cellForItemAt method return correct cell to avoid crash.
  3. After some pause let data source return 1-2 columns in numberOfColumns. Call reloadData. You can scroll SpreadsheetView like you have 100 columns.

Probably this bug can be reproduced when numberOfRows change its returned value.

Specifications

  • Xcode version: 9 beta 5
  • iOS version: 11
  • Dependency manager + version: No manager

Colour attributes of a cell are transferred to wrong cells when scrolling

If the same subclass of Cell is used for all four areas of a SpreadsheetView with a fixed row and column, then changes to colour attributes in spreadsheetView cellForItemAt are scattered over incorrect cells when the spreadsheet view if scrolled:
Example. The wrong colour attributes are cleared by a reloadData.
This does not occur if all four areas (ie top left - frozen row and column, top - frozen row, left - frozen column and non-frozen rows/columns) are associated with different subclasses of Cell:
Example 2
These examples are using the reloading branch.

reloadData() in viewWillTransition doesn't work properly in Swift 4

Expected Behavior

In my project, I have a view controller with a SpreadsheetView that autoresizes to the new size when rotating the device.

Actual Behavior

In Swift 3, the behaviour is right: the device rotates and the spreadsheet resizes accordingly.
In Swift 4, this is not valid anymore: now, when you rotate the device, the spreadsheet resizes to the PREVIOUS size instead of the new one: basically, when you rotate the device to Portrait, the spreadsheet is resized to Landscape, and vice versa.

I tried building the old project in Swift 3, and it still works as it used to, so I'm not sure it's a problem of the library, or Apple changed the behaviour of viewWillTransition.

Steps to Reproduce the Problem

The code is simple as that. Just put the viewWillTransition method in your view controller and rotate the device.

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
        spreadsheetView.reloadData()
    }

I also add the method to specify the new width of the columns:

func spreadsheetView(_ spreadsheetView: SpreadsheetView, widthForColumn column: Int) -> CGFloat {
        switch column {
        case 0:
            return spreadsheet.layer.frame.width/3
        default:
            let width = spreadsheet.layer.frame.width-(spreadsheet.layer.frame.width/3)-10
            return width/CGFloat(7)
        }
    }

Specifications

  • Xcode version: 9
  • iOS version: 10 on the device, 11 on the simulator. They both have the same issue.
  • Dependency manager + version: CocoaPods - 0.7.2 on the Sw3 project, 0.8.4 on the Sw4 project.

Enabling paging

Can't seem to enable paging at all. Crashes with reason [SpreadsheetView.SpreadsheetView _adjustedVerticalOffsetPinnedToScrollableBounds:]: unrecognized selector sent to instance 0x7f9a34f20d20

Check if spreadsheet is scrolled to bottom

I'm using latest version of SpreadsheetView. I'm finding a way to implement load more feature so I want to know if spreadsheet is scrolled to bottom. I set delegate to scrollView of spreadsheet and check for contentOffset, contentSize but I can't find any relevant values between the two.

When I scrolled to bottom:

contentOffset: (302.0, 195.0) 
contentSize: (921.02099609375, 482.0)

Do you have any suggestion for this? Thanks.

Make Cell.indexPath accessible

Hi @kishikawakatsumi, first of all, great job on this.

I'm trying to use SpreadSheetView as an editabel grid.
Therefore I have subclass cells in many different ways.
After editing a cell, i have to unselect the cell at cells indexPath.
The problem is, that indexPath is inaccessible due to 'internal' protection level.

Is it possible to provide a getter for cells indexPath, e.g.

public var cellIndexPath : IndexPath 
{
  get {
    return indexPath!
  }
}

Kind regards

Change frozen rows/columns on runtime

Hi there,

I need to change the number of columns that are frozen. I tried to set spreadsheetView.frozenColumns but this is get-only. Is this possible?

Multi-sections support

Expected Behavior

Do you have a plan to make it multi-sectioned? it would be awesome

Actual Behavior

Steps to Reproduce the Problem

Specifications

  • Xcode version: ?
  • iOS version: ?
  • Dependency manager + version: ?

Command failed due to signal: Segmentation fault: 11

I just updated Xcode to version 9. I tried converting my project from Swift 3 to 4, and SpreadsheetView gives me a red error:

Command failed due to signal: Segmentation fault: 11

I have no idea why it is and what that means. Is there someone else with the same problem?

  • Xcode version: 9
  • iOS version: iOS 10
  • Dependency manager + version: CocoaPods, 0.8.4

didSelectItemAt not always called

I have trouble getting didSelectItemAt called for tapped cells, or even UIButton:s added to cells. Sometimes the didSelectItemAt is called, but mostly not. Somehow it's more often called when I tap on cell edges, but it might be just a coincidence...
UIButton:s aren't tappable at all for now.

BTW I am still experimenting with the Timetable sample app.

The above happens if I use just one or two channels. Update: I confirmed that if I use the default channels

    let channels = [
        "ABC", "NNN", "BBC", "J-Sports", "OK News", "SSS", "Apple", "CUK", "KKR", "APAR",
        "SU", "CCC", "Game", "Anime", "Tokyo NX", "NYC", "SAN", "Drama", "Hobby", "Music"]

taps seem to work ok (didSelectItemAt at least)

If I use

	let channels = [
		"ABC"]

taps do not work well; mostly only when I tap on the grid lines between cells.

Cell widths and heights that aren't whole numbers cause graphical glitches on the cell borders.

Hi,

First off I just want to say, what a wonderful library. I didn't think I'd be able to get a grid schedule into my app for the upcoming festival this year due to time, but it's been so easy to work with, I had the schedule fully loaded in under a day and started adding my own functionality ontop of it with ease. Well done. Super flexible.

I'm working on a schedule view, where I have a day/night theme. On the day theme, things worked properly, but when I went into night theme, I started getting weird color artifacts on the borders.

There's two columns that have a persistent border visible, even though my borders are the same color as the cell backgrounds with no content. All cells get the same border applied.

I also had similar problems with a zoom functionality I implemented which adjusts the cell height. I'd get graphical glitches as I zoomed in/out showing white borders on my black background briefly, and when my zooming was done, some would sometimes remain.

I tracked it down to my dynamically generated height/widths of the cells being non whole numbers.

As soon as I took the final result of my column width, or how zoomed things were and rounded the answers down, the problems went away.

My assumption is the glitches aren't noticeable on a white background since they're white.

Here's an image of what it looks like, post zooming. Not sure if this is something fixable in the library short of rounding peoples values yourself, but should anyone encounter this, that's what's up.

screen shot 2017-08-13 at 2 30 54 pm

SpreadsheetView scroll position jumps after reloadData if you freeze columns or rows

Please fix this problem

Expected Behavior

SpreadsheetView should not change its scroll horizontal and vertical positions after reloadData method is called

Actual Behavior

SpreadsheetView jumps after reloadData if you freeze columns or rows

Steps to Reproduce the Problem

  1. Freeze one column in ViewController of ClassData example project. To make it insert
    this data source method into ViewController
    func frozenColumns(in spreadsheetView: SpreadsheetView) -> Int { return 1 }
  2. Build and run ClassData example project.
  3. Scroll SpreadsheetView to see last column on the right
  4. Tap on the top of the the last column to resort SpreadsheetView. It call reloadData method. You can see that SpreadsheetView horizontal scroll position jumps.

Specifications

  • Xcode version: 9.0 beta 2 (9M137d)
  • iOS version: iPhone 5S Simulator with iOS 11
  • Dependency manager + version: we don't use any dependency manager at the moment

How to draw Gantt Chart with percentage of work in iOS?

Sir,
I am using "kishikawakatsumi/SpreadsheetView" library provide by you.I am facing issue to draw to chart basis on percentage of work day-wise and link the two progress of different task. So could you please tell me how to edit this existing library according to my task provide by you. Please check attached screens.

I am trying from past 10 days but I am not able to get the solution. Please help me Sir.

Thank you so much in Advance.

screen shot 2017-06-23 at 5 57 07 pm

screen shot 2017-06-23 at 5 57 18 pm

Regards
Gaurav Saini

Make it possible for SpreadsheetView to be subclassed

Hi @kishikawakatsumi , first of all, fantastic job on this, I specially loved how you did the tests.
Let me try to explain where I'm coming from:

Say I want to have the same custom layout of SpreadsheetView across multiple View Controllers, it would be ideal to be able to subclass it, and have the custom behaviors on the init methods.

That being said, your current implementation uses public for the class, which doesn't allow for it to be subclassed outside it's module. I've create a pull request to change it to open.

Do you think this is a bad approach? Also, for some reason not all travis tests seem to be passing, but in my fork all your unit tests pass, and it compiles normally.

Thanks again, best regards

reloadData() doesn't refresh last 2/3 columns, row 1 of header

This can be seen more easily by viewing one of the demo apps in landscape mode. Screenshots show GanttChart demo.

func spreadsheetView(_ spreadsheetView: SpreadsheetView, didSelectItemAt indexPath: IndexPath) {

print("Selected: (row: (indexPath.row), column: (indexPath.column))")

    spreadsheetView.reloadData()  // added 

}

Add reloadData() to didSelectItemAt

Scroll in landscape mode to the end of the display. Select a column to invoke didSelectItemAt. Some end columns are not refreshed. Bug applies to row 1 of header only.

spreadsheeview reloaddata 1
spreadsheeview reloaddata 2

Visible background color looks more dark than backgroundColor property

Expected Behavior

Visible background color should be equal to backgroundColor properties of SpreadsheetView and its cells and contentView's of cells

Actual Behavior

Visible background color looks more dark than backgroundColor properties

Steps to Reproduce the Problem

  1. Make test app with SpreadsheetView.
  2. Set backgroundColor properties of SpreadsheetView and its cells and contentView's of cells to RGB 0x1E1E1E.
  3. Run the app
  4. Make a screenshot of SpreadsheetView
  5. Open screenshot with any Graphical Editor app to pick color of SpreadsheetView. Its color is more dark than RGB 0x1E1E1E.

Specifications

  • Xcode version: 9 beta 5
  • iOS version: 11
  • Dependency manager + version: No dependency manager

`spreadsheetView:didDeselectItem` delegate not called when selecting a cell that should not be selected

Consider the following scenario:

Delegate shouldSelectItemAt is configured to select (0,0) but not (0,1).

  1. When I select (0,0) it correctly selects it.
  2. When I select (0,1) it correctly deselects (0,0) and does not select (0,1).

What I expected to happen: on action 2, I expected spreadsheetView:didDeselectItem to be called, but it isn't. I will work on a pull request for this, but I'd like to hear your thoughts

Index out of range Exception for less number of rows or columns

@kishikawakatsumi Hi again, I have used Schedule app logic. I have 4 columns and 3 rows. I am rendering the data array by transposing it. For eg. By your logic, [''1", "5", "9"] are placed in first row, but after transposing data array ["1", "2", "3","4"] is placed in first row.

let data = [
        ["1", "2", "3","4"],
        ["5", "6", "7", "8"],
        ["9", "10", "11", "12"]
        ]

Logic for Transpose:

public func transpose<T>(input: [[T]]) -> [[T]] {
        if input.isEmpty { return [[T]]() }
        let count = input[0].count
        var out = [[T]](repeating: [T](), count: count)
        for outer in input {
            for (index, inner) in outer.enumerated() {
                out[index].append(inner)
            }
        }
        
        return out
    }

When I reduce number of rows or columns, then I get "fatal error: Index out of range" exception on this line let text = result[indexPath.column-1][indexPath.row-1].

For eg.

        ["1", "2", "3"],     
        ["5", "6", "7"],
        ["9", "10", "11"],
        ]

or

        ["1", "2", "3", "4"],
        ["5", "6", "7", "8"],
        ]

#Expected Behaviour
The remaining rows or columns should have "-" when no data is present. Please help.
I am using swift 3, Xcode 8.2.1

Left hand borders clipped when no intercell spacing and no grids.

I have a spreadsheet with no intercell spacing, and no grids.

For most of the cells, I have cell borders of 1 pixel solid. For one cell, I want to make the left border thicker with 3 pixels.

Since the borders are centered at the edges of the cell, my left pixel is being clipped.

screen shot 2017-08-23 at 12 27 32 pm

For the heck of it, I put some insets in the spreadsheets tableView to prove it was being clipped:

tableView.contentInset = UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5)

screen shot 2017-08-23 at 12 28 35 pm

Is there a way to have the spreadsheets tableview centered in the spreadsheetview?

Get the value of row and column when cell is tapped

Hello...! I am using Schedule App functionality. I have designed a custom gridCell to show JSON data in the rows and columns. In my case, I have to show first value in the gridCell, and remaining values in popUp View, when I tap on the cell. I have made the view in the gridCell clickable, by using UITapGestureRecognizer.

In cellForItemAt I have called the addGestureRecognizer(tapGesture) to show the popUp. Like in tableView we can get the value of the row that was clicked in didSelectRowAtIndexPath, similarly how can I get the value of 1st column and 1st row OR (nth column and mth row). Also when I tap on the cell, The pop up appears, but didSelectItemAt does not get called because it does not show row and column number.
So, how to get row and column value when I click on particular cell so that I can pass this value as a request parameter to JSON to display corresponding cell's remaining values in the popUp. Please help me with this.
I think this feature is important like uitableView's get value of selected row.

Many thanks :)

  • Xcode version: 8.2.1
  • iOS version: 10.11.5

I got little problem of connecting to the storyboard.

I can not create the SpreadSheetView on the storyboard, I know this is not an actually issue, Sorry about asking question here. I'm new to Xcode, I tried many ways to connect the code to the storyboard views, literally stuck here for a whole day, any help will be really appreciated! Thanks in advance!
Following were what I do,

  1. pod the newest version in the folder
  2. run the project using the .wcworkspace
  3. type the code on the ViewController and try to get ( @IBOutlet weak var spreadsheetView: SpreadsheetView!) hook with StoryBoard, failure.
  4. drag the SpreadSheetView in the example file and put it in my StoryBoard, I do have the SpreadSheetView on my storyboard, but it seems still not connecting with my code, so failure again.
  5. drag the frameworks from example folder to my project, I still unable to see the SpreadSheetView option in the object library...

Any help will be really appreciated! Thanks in advance!!

Specifications

  • Xcode version: 8.3.3

Variable Intercell Spacing

Is there a clean way to support variable intercell spacing? For all of the column spacing in a spreadsheet are the same value of 10, except between columns 3 and 4 where the desired column spacing is 4. The design rationale is that the content in columns 3 and 4 are very closely related and should physically be closer together on screen.

I realize I could make a cell that combines the contents of these columns for each row, but I wanted to make sure that I wasn't missing something before I go down this path. For example, a datasource callback that query the intercell spacing between columns would be ideal, but I don't see it in the current API.

If this functionality doesn't currently exist, please consider this a friendly feature request. Thanks for the continued efforts on SpreadsheetView. It has been incredibly handy!

A view added to a spread sheet view doesn't scroll

With a normal UITableView, I was able to have "overlay" views inside the tableview. The overlay views could really be shown "on top" of rows, just by adding them as subviews of the tableview itself. I tried this with SpreadsheetView but wasn't immediately able to. Would I need to add an overlay view to the internal "tableView" (which looks like a scrollview), or what is your suggestion?

Crash when in a View Controller that is in a Navigation Controller

2017-06-23 12:56:36.195516-0600 GanttChart[76766:20191693] -[SpreadsheetView.SpreadsheetView refreshControl]: unrecognized selector sent to instance 0x7fc0fdc08570 2017-06-23 12:56:36.200924-0600 GanttChart[76766:20191693] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SpreadsheetView.SpreadsheetView refreshControl]: unrecognized selector sent to instance 0x7fc0fdc08570' *** First throw call stack: ( 0 CoreFoundation 0x0000000108b72f6b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x00000001052fb121 objc_exception_throw + 48 2 CoreFoundation 0x0000000108bfd494 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132 3 UIKit 0x00000001061f8c55 -[UIResponder doesNotRecognizeSelector:] + 295 4 CoreFoundation 0x0000000108af6858 ___forwarding___ + 1432 5 CoreFoundation 0x0000000108af6238 _CF_forwarding_prep_0 + 120 6 UIKit 0x0000000106626fca +[_UINavigationControllerRefreshControlHost canHostRefreshControlOwnedByScrollView:inNavigationController:] + 233 7 UIKit 0x00000001061bf9c6 -[UINavigationController _updateNavigationBarHostedRefreshControlToHostRefreshControlForScrollView:] + 180 8 UIKit 0x00000001061bfd65 -[UINavigationController _layoutViewController:] + 149 9 UIKit 0x00000001061c0633 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 463 10 UIKit 0x00000001061c07e4 -[UINavigationController _startTransition:fromViewController:toViewController:] + 153 11 UIKit 0x00000001061c1904 -[UINavigationController _startDeferredTransitionIfNeeded:] + 857 12 UIKit 0x00000001061c2bd2 -[UINavigationController __viewWillLayoutSubviews] + 140 13 UIKit 0x00000001063ff955 -[UILayoutContainerView layoutSubviews] + 231 14 UIKit 0x00000001060b38d8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1281 15 QuartzCore 0x00000001090cd729 -[CALayer layoutSublayers] + 146 16 QuartzCore 0x00000001090c090a _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 370 17 QuartzCore 0x00000001090c0784 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24 18 QuartzCore 0x000000010904f2f0 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 326 19 QuartzCore 0x000000010907b79c _ZN2CA11Transaction6commitEv + 480 20 UIKit 0x0000000106004190 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 141 21 CoreFoundation 0x0000000108b1695c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12 22 CoreFoundation 0x0000000108afafeb __CFRunLoopDoBlocks + 203 23 CoreFoundation 0x0000000108afa7e4 __CFRunLoopRun + 1060 24 CoreFoundation 0x0000000108afa149 CFRunLoopRunSpecific + 409 25 GraphicsServices 0x000000010c2e99d7 GSEventRunModal + 62 26 UIKit 0x0000000105fe891d UIApplicationMain + 159 27 GanttChart 0x00000001048c97a7 main + 55 28 libdyld.dylib 0x000000010a68cb65 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException

Reproduce by using any of the example projects. Go to main.storyboard and add a navigation controller. Set the example view controller as the root view controller of the navigation controller.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.