Latest 0.9
Homepage https://github.com/Kevinw14/ScrollingTableViewsController
License MIT
Platforms ios 11.0
Authors

ScrollingTableViewsController is a frame work to help simplify creating a menu like design with table views side-by-side. Similar to Instagram’s notification tab.

Installation

You can use CocoaPods to include ScrollingTableViewsController into your project.

pod ScrollingTableViewsController

Usage

Begin by subclassing ScrollingTableView. This is exactly the same as subclassing UITableView, as in you set it up the same way you would a regular UITableView.

class NotificationScrollingTableView: ScrollingTableView {

let notifications: [String]

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return notifications.count
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: reuseID, for: indexPath)

        let notification = notifications[indexPath.row]

        cell.textLabel?.text = notification

        return cell
    }  
}

If you need to segue and that segue will be push on to a UINavigationController stack, you will need to subclass ScrollingTableViewControllerWithMenu. This comes with a handy delegate method. If you present the segue you can just use ScrollingTableViewControllerWithMenu directly.

Delegate

func scrollingTableView(scrollingTableView: ScrollingTableView, didSelectItemAt indexPath: IndexPath)

This delegate function is similar to UITableViews didSelectItemAt delegate function but relays the tableviews cell selected to the UIScrollView. You will have to check which ScrollingTableViewController it is coming from.

func scrollingTableView(scrollingTableView: ScrollingTableView, didSelectItemAt indexPath: IndexPath) {
  if scrollingTableView is ChatroomScrollingTableView {
    //Perform Logic
  }
}

Getting up and running

Just create your instance’s of your ScrollingTableViews

let notificationScrollingTableView = NotificationScrollingTableView()
let chatroomScrollingTableView = ChatroomScrollingTableView()

Then create an instance of ScrollingTableViewControllerWithMenu or your subclassed ScrollingTableViewControllerWithMenu. You will have to provide an array of strings as your menu names. As of now you can only have an menu bar. There are plans to bring the scrolling table views without a menu bar.

let scrollingTableViewControllerWithMenu = ScrollingTableViewControllerWithMenu(scrollingTableView: [notificationScrollingTableView, chatroomScrollingTableView], menuNames: ["Notifications", "Messages"])

Then just use scrollingTableViewControllerWithMenu instance as any UIViewController.

Contribution

If you would like to help out fork, and submit a pull request.

Latest podspec

{
    "name": "ScrollingTableViewsController",
    "version": "0.9",
    "license": {
        "type": "MIT",
        "file": "LICENSE.md"
    },
    "swift_version": "4.2",
    "platforms": {
        "ios": "11.0"
    },
    "homepage": "https://github.com/Kevinw14/ScrollingTableViewsController",
    "authors": {
        "Kevin Wood": "[email protected]"
    },
    "summary": "Framework to help simplify placing two table views side-by-side.",
    "source": {
        "git": "https://github.com/Kevinw14/ScrollingTableViewsController.git",
        "tag": "0.9"
    },
    "source_files": [
        "ScrollingTableViewsController/ScrollingTableViewControllerWithMenu.swift",
        "ScrollingTableViewsController/MenuBar.swift",
        "ScrollingTableViewsController/ScrollingView.swift",
        "ScrollingTableViewsController/ScrollingTableView.swift"
    ]
}

Pin It on Pinterest

Share This