AUNetErrorView is the control that displays empty page errors, including two prompt styles:
- Simple style (default): includes five types.
- Illustrated style: includes five types.
The two styles differ in the used prompt images, as shown in the following sample images.
Sample images
Simple style (half-screen)
Complex style (full-screen)
API description
typedef NS_ENUM(NSInteger, AUNetErrorType) {
AUNetErrorTypeLimit, // Throttling.
AUNetErrorTypeAlert, // System busy(error) or warning.
AUNetErrorTypeNetworkError, // Poor network
AUNetErrorTypeEmpty, // Empty content.
AUNetErrorTypeNotFound, // Page not found. (The image is the same as that used in AUNetErrorTypeAlert.)
AUNetErrorTypeUserLogout, // User logout.
AUNetErrorTypeFailure __attribute__((deprecated)) = AUNetErrorTypeNetworkError,
AUNetErrorTypeError __attribute__((deprecated)) = AUNetErrorTypeNetworkError, // No network connection.
AUNetErrorTypeSystemBusy __attribute__((deprecated)) = AUNetErrorTypeAlert, // Warning.
APExceptionEnumNetworkError __attribute__((deprecated)) = AUNetErrorTypeNetworkError, // No network connection.
APExceptionEnumEmpty __attribute__((deprecated)) = AUNetErrorTypeEmpty, // Empty content.
APExceptionEnumAlert __attribute__((deprecated)) = AUNetErrorTypeAlert, // Warning.
APExceptionEnumLimit __attribute__((deprecated)) = AUNetErrorTypeLimit, // Throttling.
APExceptionEnumNetworkFailure __attribute__((deprecated)) = AUNetErrorTypeNetworkError, // The network signal strength is poor
};
typedef NS_ENUM(NSInteger, AUNetErrorStyle) {
AUNetErrorStyleMinimalist, // The simple style.
AUNetErrorStyleIlustration, // The complex style.
APExceptionStyleIlustration __attribute__((deprecated)) = AUNetErrorStyleIlustration, // The complex style.
APExceptionStyleMinimalist __attribute__((deprecated)) = AUNetErrorStyleMinimalist // The simple style.
};
/**
The control that displays empty page errors.
Two prompt styles are supported:
1. Simple style (default): includes three types.
2. Illustrate style: includes seven types.
The two styles differ in the used prompt images.
*/
@interface AUNetErrorView : UIView
@property(nonatomic, strong, readonly) UIButton *actionButton; // The default text is refresh.
@property(nonatomic, strong, readonly) UIImageView *iconImageView; // The icon view.
@property(nonatomic, strong, readonly) UILabel *infoLabel; // The label of the primary prompt text.
@property(nonatomic, strong, readonly) UILabel *detailLabel; // The label of the detailed prompt text.
@property(nonatomic, strong) NSString *infoTitle; // The primary text.
@property(nonatomic, strong) NSString *detailTitle; // The secondary text.
/**
* Initialize the error view and set the error style and type.
* (When target and action are empty, the refresh button will not be displayed.)
*
* @param frame Required. The coordinates of the view.
* @param style Required. The complex or simple style.
* @param type Required. The error type.
* @param target The object to be processed in the refresh event.
* @param action The method of processing the refresh event.
*
* @return APExceptionView
*/
- (id)initWithFrame:(CGRect)frame
style:(AUNetErrorStyle)style
type:(AUNetErrorType)type
target:(id)target
action:(SEL)action;
/**
* Initialize the error view and display it on the specified view.
* (When target and action are empty, the refresh button will not be displayed.)
*
* @param parent Required. The superView of view.
* @param style Required. error style, the complex or simple style.
* @param type Required. The error type.
* @param target The object to be processed in the refresh event.
* @param action The method of processing the refresh event.
*
* @return APExceptionView
*/
+ (id)showInView:(UIView *)parent
style:(AUNetErrorStyle)style
type:(AUNetErrorType)type
target:(id)target
action:(SEL)action;
/**
* Cancel the display of the error view.
*/
- (void)dismiss;
/**
* The countdown, which can only be used in the case of throttling.
* If completeBlock is nil and the business does not set a clicking response event for actionButton, the countdown function does not take effect.
* If completeBlock isn't nil, directly execute completeBlock and hide actionButton when the countdown is over.
* To call getActionButton to add a button response event, ensure that the actionButton response event has been added.
*/
- (void)setCountdownTimeInterval:(NSInteger)startTime // The countdown start time.
completeBlock:(void (^)(void))completeBlock; // Countdown ends.
@end
Sample code
netErrorView = [[AUNetErrorView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(label.frame) + 5, self.view.width, 300) style:AUNetErrorStyleIlustration type:AUNetErrorTypeError target:self action:@selector(pressedNetErrorView)];
netErrorView.detailTitle = @"AUNetErrorTypeError type";
[self.view addSubview:netErrorView];
// Set the countdown.
[netErrorView setCountdownTimeInterval:10 completeBlock:^{
NSLog(@"Countdown ends");
}];