All Products
Search
Document Center

Exception page component

Last Updated: May 25, 2021

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)

    image

  • Complex style (full-screen)

image

API description

 
  1. typedef NS_ENUM(NSInteger, AUNetErrorType) {
  2. AUNetErrorTypeLimit, // Throttling.
  3. AUNetErrorTypeAlert, // System busy(error) or warning.
  4. AUNetErrorTypeNetworkError, // Poor network
  5. AUNetErrorTypeEmpty, // Empty content.
  6. AUNetErrorTypeNotFound, // Page not found. (The image is the same as that used in AUNetErrorTypeAlert.)
  7. AUNetErrorTypeUserLogout, // User logout.
  8. AUNetErrorTypeFailure __attribute__((deprecated)) = AUNetErrorTypeNetworkError,
  9. AUNetErrorTypeError __attribute__((deprecated)) = AUNetErrorTypeNetworkError, // No network connection.
  10. AUNetErrorTypeSystemBusy __attribute__((deprecated)) = AUNetErrorTypeAlert, // Warning.
  11. APExceptionEnumNetworkError __attribute__((deprecated)) = AUNetErrorTypeNetworkError, // No network connection.
  12. APExceptionEnumEmpty __attribute__((deprecated)) = AUNetErrorTypeEmpty, // Empty content.
  13. APExceptionEnumAlert __attribute__((deprecated)) = AUNetErrorTypeAlert, // Warning.
  14. APExceptionEnumLimit __attribute__((deprecated)) = AUNetErrorTypeLimit, // Throttling.
  15. APExceptionEnumNetworkFailure __attribute__((deprecated)) = AUNetErrorTypeNetworkError, // The network signal strength is poor
  16. };
  17. typedef NS_ENUM(NSInteger, AUNetErrorStyle) {
  18. AUNetErrorStyleMinimalist, // The simple style.
  19. AUNetErrorStyleIlustration, // The complex style.
  20. APExceptionStyleIlustration __attribute__((deprecated)) = AUNetErrorStyleIlustration, // The complex style.
  21. APExceptionStyleMinimalist __attribute__((deprecated)) = AUNetErrorStyleMinimalist // The simple style.
  22. };
 
  1. /**
  2. The control that displays empty page errors.
  3. Two prompt styles are supported:
  4. 1. Simple style (default): includes three types.
  5. 2. Illustrate style: includes seven types.
  6. The two styles differ in the used prompt images.
  7. */
  8. @interface AUNetErrorView : UIView
  9. @property(nonatomic, strong, readonly) UIButton *actionButton; // The default text is refresh.
  10. @property(nonatomic, strong, readonly) UIImageView *iconImageView; // The icon view.
  11. @property(nonatomic, strong, readonly) UILabel *infoLabel; // The label of the primary prompt text.
  12. @property(nonatomic, strong, readonly) UILabel *detailLabel; // The label of the detailed prompt text.
  13. @property(nonatomic, strong) NSString *infoTitle; // The primary text.
  14. @property(nonatomic, strong) NSString *detailTitle; // The secondary text.
  15. /**
  16. * Initialize the error view and set the error style and type.
  17. * (When target and action are empty, the refresh button will not be displayed.)
  18. *
  19. * @param frame Required. The coordinates of the view.
  20. * @param style Required. The complex or simple style.
  21. * @param type Required. The error type.
  22. * @param target The object to be processed in the refresh event.
  23. * @param action The method of processing the refresh event.
  24. *
  25. * @return APExceptionView
  26. */
  27. - (id)initWithFrame:(CGRect)frame
  28. style:(AUNetErrorStyle)style
  29. type:(AUNetErrorType)type
  30. target:(id)target
  31. action:(SEL)action;
  32. /**
  33. * Initialize the error view and display it on the specified view.
  34. * (When target and action are empty, the refresh button will not be displayed.)
  35. *
  36. * @param parent Required. The superView of view.
  37. * @param style Required. error style, the complex or simple style.
  38. * @param type Required. The error type.
  39. * @param target The object to be processed in the refresh event.
  40. * @param action The method of processing the refresh event.
  41. *
  42. * @return APExceptionView
  43. */
  44. + (id)showInView:(UIView *)parent
  45. style:(AUNetErrorStyle)style
  46. type:(AUNetErrorType)type
  47. target:(id)target
  48. action:(SEL)action;
  49. /**
  50. * Cancel the display of the error view.
  51. */
  52. - (void)dismiss;
  53. /**
  54. * The countdown, which can only be used in the case of throttling.
  55. * If completeBlock is nil and the business does not set a clicking response event for actionButton, the countdown function does not take effect.
  56. * If completeBlock isn't nil, directly execute completeBlock and hide actionButton when the countdown is over.
  57. * To call getActionButton to add a button response event, ensure that the actionButton response event has been added.
  58. */
  59. - (void)setCountdownTimeInterval:(NSInteger)startTime // The countdown start time.
  60. completeBlock:(void (^)(void))completeBlock; // Countdown ends.
  61. @end

Sample code

 
  1. netErrorView = [[AUNetErrorView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(label.frame) + 5, self.view.width, 300) style:AUNetErrorStyleIlustration type:AUNetErrorTypeError target:self action:@selector(pressedNetErrorView)];
  2. netErrorView.detailTitle = @"AUNetErrorTypeError type";
  3. [self.view addSubview:netErrorView];
  4. // Set the countdown.
  5. [netErrorView setCountdownTimeInterval:10 completeBlock:^{
  6. NSLog(@"Countdown ends");
  7. }];