Shortcat 1.0

Shortcat 1.0

Joe Fabisevich维护。



Shortcat

用猫般敏捷度导航 UITableView。一旦拥有它,你会在键盘上拥有猫而欣喜若狂。🐱


Pod Version Swift Version License MIT Plaform

展示代码

好吧,冷静一下 Jerry Maguire. 那部电影其实有点过誉了。

extension MyVERYEnthusiasticViewController: ShortcutNavigatableTableViewController {

    public override var keyCommands: [UIKeyCommand]? {
        return self.navigationAndInputKeyCommands
    }

    func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
        self.scrollViewDidEndScrollingAnimationNavigationHandler(scrollView)
    }

    func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
        self.scrollViewWillBeginDraggingNavigationHandler(scrollView)
    }

}

问答

问:就这样?您只需几行代码就能获得所有的键盘导航功能吗?

答:是的,难道你不相信我?我为什么要骗你,我甚至不认识你?

问:如果我想要添加自己的键盘快捷键怎么办?

答:self.navigationAndInputKeyCommands 是一个 UIKeyCommand 的数组,所以您可以随意添加自己的。

对于大多数用例,像这样应该很好。

public override var keyCommands: [UIKeyCommand]? {
    let customKeyCommands = [
        UIKeyCommand(input: "t", modifierFlags: .command, action: #selector(openNewTab)),
        UIKeyCommand(input: "w", modifierFlags: .command, action: #selector(closeWindow)),
        UIKeyCommand(input: "q", modifierFlags: .command, action: #selector(quitApplication)),
    ]

    return self.navigationKeyCommands + customKeyCommands
}

问:我已经问完问题了。

答:是的,我注意到了,那不是问题。

灵感

本项目受到了Donohue为IPShortcut项目所做伟大工作的启发。@donohue

相较于IPShortcut的优点

  • 使用协议/扩展,只需编写几行代码即可支持任何 UIViewController,而无需子类化。
  • 支持多个分区,而IPShortcut目前不支持。
  • 我写下它,现在我可以维护它。迫不及待地想看看结果如何。\o/

缺点

  • 不兼容 Objective-C。
  • 它不是由Brian写的,他是位了不起的家伙。
  • 我写下它,现在我可以维护它。迫不及待地想看看结果如何。\o/

安装

您可以使用CocoaPods安装Shortcat,只需将其添加到您的Podfile中。

platform :ios, '9.0'
use_frameworks!

pod 'Shortcat'

或者您可以通过下载Source文件夹中的Swift文件,并将它们拖放到您的项目中来手动安装。

关于我

嗨,我是Joe,在互联网的任何地方都可见,特别在Twitter上。

许可协议

查看许可协议获取有关如何使用Shortcat的更多信息。

就这样了?

🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱

是的。