Code Monkey home page Code Monkey logo

reverseextension's Introduction

ReverseExtension

Version Language License Platform Carthage compatible

UITableView extension that enabled to insert cell from bottom of tableView.

Concept

It is difficult to fill a tableview content from bottom. So, ReverseExtension rotate both of UITableView and UITableViewCell like this images.

If you implement those in ViewController, it will have been fat. So, escaping those implementation to re namespace property, and hiding those complex implementation. In addition, you can rollback to normal behaviour, only removing re namespace.

Example

import UIKit
import ReverseExtension

class ViewController: UIViewController {
    @IBOutlet weak var tableView: UITableView!

    override func viewDidLoad() {
        super.viewDidLoad()
        tableView.re.dataSource = self
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")

        //You can apply reverse effect only set delegate.
        tableView.re.delegate = self
        tableView.re.scrollViewDidReachTop = { scrollView in
            print("scrollViewDidReachTop")
        }
        tableView.re.scrollViewDidReachBottom = { scrollView in
            print("scrollViewDidReachBottom")
        }
    }
}

extension ViewController: UITableViewDelegate {
    //ReverseExtension also supports handling UITableViewDelegate.
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        print("scrollView.contentOffset.y =", scrollView.contentOffset.y)
    }
}

Requirements

  • Swift 5
  • Xcode 12 or greater
  • iOS 10 or greater

Installation

CocoaPods

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

pod "ReverseExtension"

Carthage

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

github "marty-suzuki/ReverseExtension"

Make sure to add ReverseExtension.framework to "Linked Frameworks and Libraries" and "copy-frameworks" Build Phases.

Special Thanks

TouchVisualizer (Created by @morizotter)

Author

marty-suzuki, [email protected]

License

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

reverseextension's People

Contributors

ca-atmosphere avatar getaaron avatar marty-suzuki avatar matthiasnagel avatar sattler avatar toshi0383 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

reverseextension's Issues

Support Swift 4.2

When can we expect an update for swift 4.2? Do you need any help with this?

Swipe to reveal cells

Hey,

Am I correct in assuming that swipe to delete won't work with this anymore since the tableView and the cells are rotated?

Thanks

Content Insets

Cant change content insets top and bottom when set my table view as delegate for re.
but left and right works fine

cause UITableViewController reverse

I use reverse tableview in my chat view . Although somewhere else I use a UITableViewController. When I enter UITableViewController and push to another view an then pop back. The TableViewController has been reversed. Is there anyway to disable the effect?

origin table is reversed

Excuse me, I have a tableview to show all things, after I install your framework, and use in my target page, until here is fine, but when I back the last page the tableview is reverse.

ask1

Custom section header view not working.

Hi,

If I use method for custom section header view than header is not presented properly:

func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?

Can you provide me instructions what should I do to make this work, thank you.

Misspell of indexPath and in rectForRow unused variable

In ReverseExtension.swift, in function rectForRow, indexPath is misspelled; therefore, using the incorrect variable may cause weird behavior:

        public func rectForRow(at indexPath: IndexPath) -> CGRect {
            let indexPaht = reversedIndexPath(with: indexPath)
            return nonNilBase.rectForRow(at: indexPath)
        }

indexPaht should be indexPath

Amazing!

You are so beautiful a girl !
Love this!

Terminating app due to uncaught exception 'NSInternalInconsistencyException'

I am getting this error, after I hit Back in the navigation controller. My ChatViewController (which uses ReverseExtension) is succesfully deiniting as you can see from the logs below, also another observer that I use (ContextWatcher) is deiniting as well.

I put a break point in deinit and the below error occures before the break point. Any ideas?

[00070]:ChatViewController.swift :deinit........................ :10:26:52 -------------------------
[00071]:ChatViewController.swift :deinit........................ :10:26:52 | ViewController deinit |
[00072]:ChatViewController.swift :deinit........................ :10:26:52 -------------------------
[00075]:CDContextWatcher.swift :deinit........................ :10:26:52 DEINIT ContextWatcher
2017-04-02 10:26:52.602283 LetsGoApp[401:153893] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x1031e0a00 of class UITableView was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x1708390e0> (
<NSKeyValueObservance 0x170a5b780: Observer: 0x1701cb8b0, Key path: contentInset, Options: <New: YES, Old: YES, Prior: NO> Context: 0x0, Property: 0x17084d200>
)'

Autocorrect-bubble reversed

I tried something similar a while ago when implementing a messenger-functionality in our app. We came up with the same idea of reverting the tableview and then reverting the cells. So, the cell at the bottom contained a UITextField to enter the text to the other user. A problem we stumbled upon was the autocorrect-bubble:
screen shot 2017-05-10 at 08 02 12
In this example i just added a textfield to the cell to see what happens… if you type in something and autocorrect comes up with some better stuff, the bubble is reversed. We tried to walk through the view-hierarchy to rotate the bubble, but no solution was satisfying... do you have any idea how to take care of this?

Swift 5

Is there any chance to update this library to support swift 5 ? I tried to compile it against swift 5 (after fixing a few renames), but it looks like it always gets the first item from the datasource (using similar setup from the sample project)

tvOS support

Do reverseExtension support for tvOS? if not, in near future?

Error in Xcode9 Swift 4

On line 163 in ReverseExtension.swift

            contentInsetObserver?.didChange = { [weak self] _ in
                DispatchQueue.main.async {
                    self?.configureTableViewInsets()
                }
            }

Gives a compile error.

Changing it to:

            contentInsetObserver?.didChange = { [weak self] (_, _) in
                DispatchQueue.main.async {
                    self?.configureTableViewInsets()
                }
            }

Works.

update pod version number

After my last pull request the version number hasn't been updated and that's why pod update ReverseExtension pulls the old version

Best regards,
Patrick

reversedIndexPath is wrong when using sections

The reversedIndexPath method returns the wrong IndexPath when using sections. The unexpected behaviour emerges when calling methods like `scrollToRow(at: IndexPath, _, _) from the ViewController.

Crash When Scrolling to the Top

In Xcode 10/Swift 4.2/iOS 12 Simulator, both my app and the included sample app crash if there are tableviewcells on the table and you try to scroll beyond the top of the view.

The issue doesn't seem to appear in Xcode 9/Swift 4.1/iOS 11.

The screen turn upside down

I updated to 0.4.5 and found out a bug.
The screen(tableview) will always turn upside down then I pop a view controller.
This bug only appears on 0.4.5.

Crash in Object-C

UMLOG: error: session_id=0A305CA2267A57BCE3328B677E10407C, context=An instance 0x7fab039b2400 of class UITableView was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x61000023b420> (
<NSKeyValueObservance 0x61000045e690: Observer: 0x6100001de4b0, Key path: contentInset, Options: <New: YES, Old: YES, Prior: NO> Context: 0x0, Property: 0x608000440d80>

Can you help me with this problem?

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.