/vehicle-keyboard-ios

停车王车牌号码专用键盘 - iOS

Primary LanguageObjective-COtherNOASSERTION

停车王车牌号码专用键盘 VehicleKeyboard - iOS

VehicleKeyboard是停车王品牌的各端产品线的基础组件,专为提高**车牌号码输入速度而定制开发的专用键盘组件,包括以下三个项目:

概述

键盘作为inputView使用

  • 可直接赋给textField或textView,使用方式和常规键盘一致
  • 提供包含自定义输入框的使用方式,逻辑已实现,使用者需自行修改样式

已适配横竖屏、iPhone X

使用组件

直接作为inputView使用

#import "PWPlateKeyBoardWindow.h"

__weak typeof (self)weakSelf = self;
self.textField.inputView = [PWPlateKeyBoardWindow shareInstance];
[PWPlateKeyBoardWindow shareInstance].buttonClickBlock = ^(PWPlteKeyBoardButtonType buttonType, NSString *text) {
    switch (buttonType) {
        //当键位类型为确定时,收回键盘
        case PWPlteKeyBoardButtonTypeDone:
            [weakSelf.textField resignFirstResponder];
            break;
        default:
            //改变textField的text
            [weakSelf.textField changetext:text];
            //将对应的改动传递给js,使键盘的刷新获取对应的键位
            [[PWPlateKeyBoardWindow shareInstance] setPlate:weakSelf.textField.text type:[PWPlateKeyBoardWindow shareInstance].type index:[weakSelf.textField offsetFromPosition:weakSelf.textField.beginningOfDocument toPosition:weakSelf.textField.selectedTextRange.start]];
            break;
    }
};

自定义输入框

#import "PWHandler.h"

//实例化PWHandler,同时注册UICollectionViewCell,此cell需要继承PWSegmentCollectionViewCell,供使用者自定义样式
self.handler = [[PWHandler alloc] initWithReuseIdentifier:NSStringFromClass(TestCollectionViewCell.class)];

//设置PWHandler中UICollectionView的应用,在PWHandler实现中用于UICollectionView的相关操作
self.handler.collectionView = self.collectionView;

//PWHandler中(NSString *)plate提供车牌号的主动设置,可也用此属性过去当前的车牌号
//self.handler.plate = @"京A23456";

//使用者自己提供的UICollectionView,仅需注册UICollectionViewCell,同时将代理引用与PWHandler关联
[self.collectionView registerClass:TestCollectionViewCell.class forCellWithReuseIdentifier:NSStringFromClass(TestCollectionViewCell.class)];
self.collectionView.delegate = self.handler;
self.collectionView.dataSource = self.handler;
self.collectionView.clipsToBounds = NO;

主要类的介绍

详细属性介绍请看注释

  • PWKeyboardView:核心类,主要实现键盘逻辑与布局;
  • PWHandler:自定义输入框的核心类,主要实现输入框逻辑,若使用者希望更好的调整布局,可继承此类重写layout的代理方法;
  • PWSegmentCollectionViewCell:自定义输入框cell,使用者可通过继承该类,对cell样式及各状态效果进行调整;

注意

  • 直接作为inputView使用时,当输入长度超过车牌规定长度时,键盘会自动收起
  • 键盘除了主题色外,其他样式暂不支持修改

cocoaPods

会自动引入JSONModel

pod 'PWKeyboard'

维护