iOS 的 NSNotificationCenter 中哪些通知由系统自动发送

2025-02-25 14:24:07
推荐回答(1个)
回答1:

在UIWindows.h中标注了一部分枚举

// 此部分注意UIWindows层级以及状态
UIKIT_EXTERN const UIWindowLevel UIWindowLevelNormal;

UIKIT_EXTERN const UIWindowLevel UIWindowLevelAlert;

UIKIT_EXTERN const UIWindowLevel UIWindowLevelStatusBar __TVOS_PROHIBITED;

UIKIT_EXTERN NSString *const UIWindowDidBecomeVisibleNotification; // nil

UIKIT_EXTERN NSString *const UIWindowDidBecomeHiddenNotification; // nil

UIKIT_EXTERN NSString *const UIWindowDidBecomeKeyNotification; // nil

UIKIT_EXTERN NSString *const UIWindowDidResignKeyNotification; // nil

// Each notification includes a nil object and a userInfo dictionary containing the

// begining and ending keyboard frame in screen coordinates. Use the various UIView and

// UIWindow convertRect facilities to get the frame in the desired coordinate system.

// Animation key/value pairs are only available for the "will" family of notification.

//此部分监控键盘状态

UIKIT_EXTERN NSString *const UIKeyboardWillShowNotification __TVOS_PROHIBITED;

UIKIT_EXTERN NSString *const UIKeyboardDidShowNotification __TVOS_PROHIBITED;

UIKIT_EXTERN NSString *const UIKeyboardWillHideNotification __TVOS_PROHIBITED;

UIKIT_EXTERN NSString *const UIKeyboardDidHideNotification __TVOS_PROHIBITED;

UIKIT_EXTERN NSString *const UIKeyboardFrameBeginUserInfoKey NS_AVAILABLE_IOS(3_2) __TVOS_PROHIBITED; // NSValue of CGRect

UIKIT_EXTERN NSString *const UIKeyboardFrameEndUserInfoKey NS_AVAILABLE_IOS(3_2) __TVOS_PROHIBITED; // NSValue of CGRect

UIKIT_EXTERN NSString *const UIKeyboardAnimationDurationUserInfoKey NS_AVAILABLE_IOS(3_0) __TVOS_PROHIBITED; // NSNumber of double

UIKIT_EXTERN NSString *const UIKeyboardAnimationCurveUserInfoKey NS_AVAILABLE_IOS(3_0) __TVOS_PROHIBITED; // NSNumber of NSUInteger (UIViewAnimationCurve)

UIKIT_EXTERN NSString *const UIKeyboardIsLocalUserInfoKey NS_AVAILABLE_IOS(9_0) __TVOS_PROHIBITED; // NSNumber of BOOL

// Like the standard keyboard notifications above, these additional notifications include

// a nil object and begin/end frames of the keyboard in screen coordinates in the userInfo dictionary.

UIKIT_EXTERN NSString *const UIKeyboardWillChangeFrameNotification NS_AVAILABLE_IOS(5_0) __TVOS_PROHIBITED;

UIKIT_EXTERN NSString *const UIKeyboardDidChangeFrameNotification NS_AVAILABLE_IOS(5_0) __TVOS_PROHIBITED;

// These keys are superseded by UIKeyboardFrameBeginUserInfoKey and UIKeyboardFrameEndUserInfoKey.

UIKIT_EXTERN NSString *const UIKeyboardCenterBeginUserInfoKey NS_DEPRECATED_IOS(2_0, 3_2) __TVOS_PROHIBITED;

UIKIT_EXTERN NSString *const UIKeyboardCenterEndUserInfoKey NS_DEPRECATED_IOS(2_0, 3_2) __TVOS_PROHIBITED;

UIKIT_EXTERN NSString *const UIKeyboardBoundsUserInfoKey NS_DEPRECATED_IOS(2_0, 3_2) __TVOS_PROHIBITED;

以上枚举的NSString *const的字符串, 均可以在类中直接注册观察者,在UIWindows或者键盘变化会自动收到系统通知.