iOS的一些常見系統Notification(系統消息)

一、鍵盤

1、UIKeyboardWillShowNotification 即將顯示
2、UIKeyboardDidShowNotification 顯示完畢
3、UIKeyboardWillHideNotification 即將隱藏
4、UIKeyboardDidHideNotification 隱藏完畢
5、UIKeyboardWillChangeFrameNotification 位置尺寸即將發生改變
6、UIKeyboardDidChangeFrameNotification 位置尺寸改變完畢

系統發出鍵盤通知時,會附帶一下跟鍵盤有關的額外信息(字典),字典常見的key如下:
UIKeyboardFrameBeginUserInfoKey 鍵盤剛開始的frame
UIKeyboardFrameEndUserInfoKey 鍵盤最終的frame(動畫執行完畢后)
UIKeyboardAnimationDurationUserInfoKey 鍵盤動畫的時間
UIKeyboardAnimationCurveUserInfoKey 鍵盤動畫的執行節奏(快慢)

二、窗口

1、UIWindowDidBecomeVisibleNotification 窗口可見
2、UIWindowDidBecomeHiddenNotification 窗口隱藏
3、UIWindowDidBecomeKeyNotification
4、UIWindowDidResignKeyNotification

三、程序消息

1、UIApplicationDidEnterBackgroundNotification 已經進入后臺
2、UIApplicationWillEnterForegroundNotification 將要進入前臺
3、UIApplicationDidFinishLaunchingNotification 已經加載完成
4、UIApplicationDidBecomeActiveNotification 已經激活
5、UIApplicationWillResignActiveNotification 將要激活
6、UIApplicationDidReceiveMemoryWarningNotification 內存警告
7、UIApplicationWillTerminateNotification 將要終止

8、UIApplicationSignificantTimeChangeNotification 當系統時間發生改變時(新的一天開始或時區變化)

9、UIApplicationWillChangeStatusBarOrientationNotification 將要改變狀態欄方向
10、UIApplicationDidChangeStatusBarOrientationNotification 已經改變 狀態欄方向
UIApplicationStatusBarOrientationUserInfoKey
11、UIApplicationWillChangeStatusBarFrameNotification 將要改變狀態欄frame
12、UIApplicationDidChangeStatusBarFrameNotification 狀態欄frame改變
UIApplicationStatusBarFrameUserInfoKey

13、UIApplicationBackgroundRefreshStatusDidChangeNotification 后臺下載狀態發生改變時通知
14、UIApplicationProtectedDataWillBecomeUnavailable 設備鎖屏
15、UIApplicationProtectedDataDidBecomeAvailable 設備解鎖
16、UIApplicationUserDidTakeScreenshotNotification 設備截屏

四、電池、方向、傳感器

1、UIDeviceOrientationDidChangeNotification 方向
2、UIDeviceBatteryStateDidChangeNotification 電池狀態
3、UIDeviceBatteryLevelDidChangeNotification 電池電量
4、UIDeviceProximityStateDidChangeNotification 近距離傳感器(比如設備貼近了使用者的臉部)

五、音視頻

1、MPMediaLibraryDidChangeNotification
2、MPMusicPlayerControllerPlaybackStateDidChangeNotification
3、MPMusicPlayerControllerNowPlayingItemDidChangeNotification
4、MPMusicPlayerControllerVolumeDidChangeNotification

六、偏好設置

1、NSUserDefaultsSizeLimitExceededNotification 當用戶默認數據中存儲更多數據時發布
2、NSUbiquitousUserDefaultsNoCloudAccountNotification 當設置了云默認時,但沒有登錄iCloud用戶發布
3、NSUbiquitousUserDefaultsDidChangeAccountsNotification 當用戶更改主iCloud帳戶時發布
4、NSUbiquitousUserDefaultsCompletedInitialSyncNotification 主線程發布,默認完成下載數據,無論是第一次設備連接到一個iCloud帳戶,或當用戶切換他們的主要iCloud帳戶
5、NSUserDefaultsDidChangeNotification 在當前進程中更改用戶默認值時發布

七、其他

1、NSCurrentLocaleDidChangeNotification 本地化語言變化

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容