GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ipedro/UIKeyCommandTableView

BranchesTags
Open more actions menu

Latest commit

 

History

19 Commits
19 Commits

Folders and files

NameName
Last commit message
Last commit date
.swiftpm/xcode/package.xcworkspace
.swiftpm/xcode/package.xcworkspace
 
 
Sources/UIKeyCommandTableView
Sources/UIKeyCommandTableView
 
 
Tests
Tests
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
Package.swift
Package.swift
 
 
README.md
README.md
 
 

Repository files navigation

UIKeyCommandTableView

A custom UITableView subclass that enables keyboard-based navigation and selection.

Overview

UIKeyCommandTableView allows you to use hardware keyboard shortcuts to navigate and interact with table views. It supports customizable key commands and delegate callbacks for handling selection and activation events.

Features

  • Keyboard navigation with arrow keys.
  • Selection and activation using space bar or return key.
  • Customizable key command options.
  • Delegate support for responding to key command events.
  • Built-in tests ensuring reliability.

Installation

UIKeyCommandTableView is available via Swift Package Manager. Add the following dependency to your Package.swift:

dependencies: [
    .package(url: "https://github.com/ipedro/UIKeyCommandTableView.git", from: "1.0.0")
]

Then, add "UIKeyCommandTableView" as a dependency for your target.

Usage

Import the package into your view controller:

import UIKeyCommandTableView

Use UIKeyCommandTableView as you would any UITableView and implement the UITableViewKeyCommandsDelegate to respond to first responder events and key command actions.

Basic Initialization

Instantiate and add a UIKeyCommandTableView to your view controller:

class MyViewController: UIViewController, UITableViewKeyCommandsDelegate {
    let tableView = UIKeyCommandTableView()

    override func viewDidLoad() {
        super.viewDidLoad()
        // Setup table view frame, dataSource, delegate, etc.
        tableView.frame = view.bounds
        tableView.keyCommandsDelegate = self
        view.addSubview(tableView)
    }

    // UITableViewKeyCommandsDelegate methods
    func tableViewDidBecomeFirstResponder(_ tableView: UIKeyCommandTableView) { 
        // handle event
    }
    
    func tableViewDidResignFirstResponder(_ tableView: UIKeyCommandTableView) { 
        // handle event
    }
    
    func tableViewKeyCommandSelectionBelowBounds(_ tableView: UIKeyCommandTableView) -> UIKeyCommandTableView.OutOfBoundsBehavior {
       return .wrapAround
    }
    
    func tableViewKeyCommandSelectionAboveBounds(_ tableView: UIKeyCommandTableView) -> UIKeyCommandTableView.OutOfBoundsBehavior {
       return .wrapAround
    }
}

Customizing Key Commands

Customize key command options to fit your needs:

// In your view controller or table view setup:
tableView.selectPreviousKeyCommandOptions = [.arrowUp, .command(.arrowUp)]
tableView.selectNextKeyCommandOptions = [.arrowDown, .command(.arrowDown)]
tableView.activateSelectionKeyCommandOptions = [.spaceBar, .return]

Requirements

  • iOS 11 or later

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Readme
MIT license
Activity

Stars

6 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.