受ZenKeyboard启发的Numeric键盘,用于UITextField的UIPopoverController。
@property(nonatomic, weak) id<BSNumPadPopoverConotrollerDelegate> padDelegate;
@property(nonatomic, assign) BSPopoverPosition padPosition;
- (instancetype)initWithTextField:(UITextField *)textField andTextFieldFormat:(BSTextFieldFormat)textFieldFormat andNextKey:(BOOL)nextKeyExist nextButtonTitle:(NSString *)nextButtonTitle;
- (void)dismissPopoverAnimated:(BOOL)animated onNextKeyPress:(BOOL)nextKeyPressed;
以下为Popover位置和TextField格式:
typedef NS_ENUM(NSUInteger, BSPopoverPosition)
{
BSPopoverPositionLeft,
BSPopoverPositionTop,
BSPopoverPositionRight,
BSPopoverPositionBottom,
};
typedef NS_ENUM(Byte, BSTextFieldFormat)
{
BSTextFieldFormatFloat,
BSTextFieldFormatDate,
BSTextFieldFormatInteger
};
BSNumPadPopoverConotrollerDelegate协议
@optional
- (BOOL)isValidTextFieldText:(NSString *)text onNextKeyPress:(BOOL)nextPressed;
- (void)popoverWillAppear;
- (void)popoverDidDisappearOnNextPress:(BOOL)nextPressed;
isValidTextFieldText:onNextKeyPress:
在输入TRUE
后将关闭数字键盘视图。
self.numPadPopoverConotroller = [[BSNumPadPopoverConotroller alloc] initWithTextField:textField andTextFieldFormat:BSTextFieldFormatFloat andNextKey:YES nextButtonTitle:nil];
self.numPadPopoverConotroller.padDelegate = self;
self.numPadPopoverConotroller.padPosition = BSPopoverPositionBottom;
数字键盘出现在textFieldDidBeginEditing:
消息上。
克隆项目并运行。您可以在BSTestViewController
中找到使用示例。
这个类已测试回iOS 6.0。
Cocoapods: pod 'BSNumPad'
手动: 将BSNumPad文件夹复制到您的项目中
导入头文件
#import "BSNumPadPopoverConotroller.h"
此代码根据MIT许可证发布。有关详细信息,请参阅LICENSE文件。