Numeric keypad component

更新时间:
复制 MD 格式

AUNumKeyboards is a custom numeric keypad component for iOS apps built on mPaaS.

AUNumKeyboards replaces the system keyboard with a custom numeric keypad attached to a UITextField. Use it for PIN entry, ID card number input, or any scenario requiring a controlled numeric input surface without a decimal point or with a configurable submit button.

The component is iOS-only and has no effect on Android targets.

Sample images

AUNumKeyboards supports two modes. Choose the mode that matches your input context:

  • Common mode — general numeric input: amounts, PINs, and numeric form fields.

  • Chat mode — numeric input in messaging or in-app chat flows.

AUNumKeyboardModeInvalid indicates the keypad is unavailable and must not be passed to the factory methods.

  • Common mode

    image.png

  • Chat mode

API reference

typedef NS_ENUM(NSInteger, AUNumKeyboardMode) {
        AUNumKeyboardModeCommon,  // The numeric keypad is in common mode.
        AUNumKeyboardModeChat,    // The keypad is in chat mode.
        AUNumKeyboardModeInvalid  // The keypad is in invalid mode and unavailable.
};

/**
 Define a numeric keypad.
 */
@interface AUNumKeyboards : UIView

/**
 *  Creates a numeric keypad component in common mode.
 *
 *  @return         The initialized numeric keypad component.
 */
+ (AUNumKeyboards *)sharedKeyboard;

/**
 *  Creates a numeric keypad component in the specified mode.
 *
 *  @param mode     The numeric keypad mode.
 *
 *  @return         The initialized numeric keypad component.
 */
+ (AUNumKeyboards *)sharedKeyboardWithMode:(AUNumKeyboardMode)mode;

/**
 *  The text field to receive input. Set the keypad Y-coordinate externally when using this property.
 */
@property (nonatomic, weak) id<UITextInput> textInput;

/**
 *  Specifies whether ID card number input mode is enabled.
 */
@property (nonatomic, assign) BOOL idNumber;

/**
 *  The current keypad mode (read-only).
 */
@property (nonatomic, assign, readonly) AUNumKeyboardMode mode;

/**
 *  Specifies whether to hide the decimal point key.
 */
@property (nonatomic, assign) BOOL dotHidden;

/**
 *  Specifies whether to hide the dismiss button.
 */
@property (nonatomic, assign) BOOL dismissHidden;

/**
 *  Specifies whether the submit button is enabled.
 */
@property (nonatomic, assign) BOOL submitEnable;

/**
 *  The label on the submit button. Maximum six characters.
 */
@property (nonatomic, strong) NSString *submitText;

Properties summary

Property

Type

Description

textInput

id<UITextInput>

The text field to receive input. Set the keypad Y-coordinate externally when using this property.

idNumber

BOOL

Set to YES to enable ID card number input mode.

mode

AUNumKeyboardMode

The current keypad mode (read-only).

dotHidden

BOOL

Set to YES to hide the decimal point key.

dismissHidden

BOOL

Set to YES to hide the dismiss button.

submitEnable

BOOL

Set to YES to enable the submit button.

submitText

NSString *

The label on the submit button. Maximum six characters.

Code sample

UITextField *numTextField = ...
numTextField.inputView = [AUNumKeyboards sharedKeyboardWithMode:AUNumKeyboardModeCommon]; // For chat mode, use AUNumKeyboardModeChat.
[self.view addSubview:numTextField];