All Products
Search
Document Center

Mobile Platform as a Service:Input dialog

Last Updated:Jul 20, 2023

AUInputDialog specifies the style of a pop-up window with an input box. The Window level of the pop-up window follows the logic self.windowLevel = UIWindowLevelAlert - 1.

API description

@interface AUInputDialog : AUDialogBaseView

/// The input box.
@property (nonatomic, strong, readonly) UITextField *textField;

/**
Specify whether this instance is displayed. This applies when a pointer points at this instance. 
If another dialog box overrides this one, the attribute value is fixed as YES. 
*/
@property (nonatomic, assign, readonly) BOOL isDisplay;

/**
* The title.
*/
@property (nonatomic, strong) NSString *title;

/**
* The text message.
*/
@property (nonatomic, strong) NSString *message;

/**
The method of dialog box initialization without the button title. 

@param title    The title.
@param message  The message details.
@return         The AUInputDialog instance.
*/
- (instancetype)initWithTitle:(NSString *)title
message:(NSString *)message;


/**
The AUInputDialog instance initialization method.

@param title        The title.
@param message      The message details.
@param placeholder  The placeholder in the text box.
@param delegate     The delegate object.
@param buttonTitle  The button title.
@return             The AUInputDialog instance.
*/
- (instancetype)initWithTitle:(NSString *)title
message:(NSString *)message
placeholder:(NSString *)placeholder
delegate:(id<AUDialogDelegate>)delegate
buttonTitles:(NSString *)buttonTitle, ... NS_REQUIRES_NIL_TERMINATION;

- (instancetype)initWithCustomView:(UIView *)customView; // The custom view.

/// The disabled initialization method.
- (instancetype)init NS_UNAVAILABLE;

/**
The dialog box display method. 
*/
- (void)show;

/**
The method of closing the dialog box. If will/didDismissWithButtonIndex is monitored, the index called back is 0 by default.
*/
- (void)dismiss;

/**
Hide all dialog views in the dialog window.
*/
+ (void)dismissAll;

/**
Set the color of the text to gray. Default value: YES.
*/
- (void)setGrayMessage:(BOOL)grayMessage;

/**
Set the text alignment mode.

@param alignment The alignment mode.
*/
- (void)setMessageAlignment:(NSTextAlignment)alignment;

/**
Add a button and its callback method. 

@param buttonTitle  The button title.
@param actionBlock  The callback of the button tapping action.
*/
- (void)addButton:(NSString *)buttonTitle actionBlock:(AUDialogActionBlock)actionBlock;

Code sample

  • Common style

AUInputDialog *dialog = [[AUInputDialog alloc] initWithTitle:@"Title" message:@"The message may contain the sound icon and button of a notification alarm. This message can be sent to " placeholder:@"To friends." delegate:self buttonTitles:@"Cancel", @"Main action", nil];
[dialog show];
  • Custom style

UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 240, 60)];
customView.backgroundColor = [UIColor greenColor];
AUInputDialog *dialog = [[AUInputDialog alloc] initWithCustomView:customView];
[dialog addButton:@"Cancel" actionBlock:nil];
[dialog addButton:@"OK" actionBlock:nil];
[dialog show];