UIkit架構之uiUIapplication

來源:互聯網
上載者:User

標籤:

1.繼承鏈:uiresponder:NSObject

2.使用 sharedApplication方法來存取對象

3.這個類可以遵守協議是UIApplicationDelegate

4.擷取app的執行個體

    (1)+ (UIApplication *)sharedApplication  :返回單個app執行個體

5.擷取app委託

    (1)@property(nonatomic, assign) id< UIApplicationDelegate > delegate  :設定委託

6.擷取app視窗

    (1)@property(nonatomic, readonly) UIWindow *keyWindow  :app的關鍵視窗

    (2)@property(nonatomic, readonly) NSArray <__kindof UIWindow *> *windows  :返回app可見的,隱藏的視窗組成的數組

7.控制和控制事件

    (1)- (void)sendEvent:(UIEvent *)event  :給app裡面合適的響應對象派遣事件

    (2)- (BOOL)sendAction:(SEL)action
                to:(id)target
              from:(id)sender
          forEvent:(UIEvent *)event
  :

action

A selector identifying an action method. See the discussion for information on the permitted selector forms.

target

The object to receive the action message. If target is nil, the app sends the message to the first responder, from whence it progresses up the responder chain until it is handled.

sender

The object that is sending the action message. The default sender is the UIControl object that invokes this method.

event

A UIEvent object that encapsulates information about the event originating the action message.

    (3)- (void)beginIgnoringInteractionEvents  :開始動畫和轉換之前調用這個方法通知接收者延遲處理和觸摸相關的事件

    (4)- (void)endIgnoringInteractionEvents  :調用上面的方法、動畫或者轉換之後調用這個方法通知接收者重新處理和觸摸相關的事件

    (5)- (BOOL)isIgnoringInteractionEvents  :返回布爾值是否讓接收者忽視由螢幕上出現的觸摸事件

    (6)@property(nonatomic) BOOL applicationSupportsShakeToEdit  :一個布爾值決定了裝置搖動是否可以顯示undo-redo user interface

8.開啟一個URL資源

    (1)- (BOOL)openURL:(NSURL *)url  :嘗試開啟指定的URL,返回的值確定是否能夠開啟

    (2)- (BOOL)canOpenURL:(NSURL *)url  :返回布爾值確定app是否能夠開啟某個指定的URL路徑

9.配置使用者通知設定

    (1)- (void)registerUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings  :註冊通知偏好

    (2)- (UIUserNotificationSettings *)currentUserNotificationSettings  :返回當前為app設定的通知設定

10.註冊遠端通知

    (1)- (void)registerForRemoteNotifications  :登記遠端通知

    (2)- (void)unregisterForRemoteNotifications  :拒絕接受任何的遠程通知

    (3)- (BOOL)isRegisteredForRemoteNotifications  :返回布爾值確定當前登記的是否為遠程通知

11.登記本地通知

    (1)- (void)scheduleLocalNotification:(UILocalNotification *)notification  :傳遞本地封裝的時間通知

    (2)- (void)presentLocalNotificationNow:(UILocalNotification *)notification  :立即顯示本地的通知

    (3)- (void)cancelLocalNotification:(UILocalNotification *)notification  :取消傳遞指定的本地時間表通知

    (4)@property(nonatomic, copy) NSArray <UILocalNotification *> *scheduledLocalNotifications  :所有目前時間表的本地通知

12.管理後台執行

    (1)@property(nonatomic, readonly) UIApplicationState applicationState  :app運行時的狀態

    (2)@property(nonatomic, readonly) NSTimeInterval backgroundTimeRemaining  :app在後台啟動並執行時間

    (3)@property(nonatomic, readonly) UIBackgroundRefreshStatus backgroundRefreshStatus  :有能力在後台執行的程式

    (4)- (void)setMinimumBackgroundFetchInterval:(NSTimeInterval)minimumBackgroundFetchInterval  :指定程式等待執行的時間

    (5)- (UIBackgroundTaskIdentifier)beginBackgroundTaskWithName:(NSString *)taskName
                                        expirationHandler:(void (^)(void))handler
  :使用指定name來標誌一個新的長時間啟動並執行背景工作

    (6)-(UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler:(void (^)(void))handler  :標示一個新長時間啟動並執行背景工作的開始

    (7)- (void)endBackgroundTask:(UIBackgroundTaskIdentifier)identifier  :標示指定的背景工作已經結束

13.管理app的閑置時間

    (1)@property(nonatomic, getter=isIdleTimerDisabled) BOOL idleTimerDisabled  :閑置時間是否能夠為app所用

14.管理恢複行為的狀態

    (1)- (void)extendStateRestoration  :告訴app代碼開始非同步恢複狀態

    (2)- (void)completeStateRestoration  :告訴app已經非同步恢複了狀態

    (3)- (void)ignoreSnapshotOnNextApplicationLaunch  :Prevents the app from using the recent snapshot image during the next launch cycle.

    (4)+ (void)registerObjectForStateRestoration:(id<UIStateRestoring>)object
                    restorationIdentifier:(NSString *)restorationIdentifier
  :為狀態恢複系統註冊一個自訂對象

15.管理Home Screen Quick Actions for 3D Touch

    (1)@property(nonatomic, copy) NSArray <UIApplicationShortcutItem *> *shortcutItems  :Set this property to register an array of dynamic quick actions to display on the Home screen when a user presses your app icon.

16.決定可以保護的內容

    (1)@property(nonatomic, readonly, getter=isProtectedDataAvailable) BOOL protectedDataAvailable  :傳回值確定內容是否是被保護的

17.註冊遠端控制事件

    (1)- (void)beginReceivingRemoteControlEvents  :告訴app開始接受遠端控制事件

    (2)- (void)endReceivingRemoteControlEvents  :告訴app結束接受遠端控制事件

18.控制app的顯示

    (1)@property(nonatomic, readonly) CGRect statusBarFrame  :讀取狀態列的位置和大小

    (2)@property(nonatomic, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible  :網路是否能夠使用

    (3)@property(nonatomic) NSInteger applicationIconBadgeNumber  :The number currently set as the badge of the app icon in Springboard.  

    (4)@property(nonatomic, readonly) UIUserInterfaceLayoutDirection userInterfaceLayoutDirection  :返回使用者介面的布局方向

18.擷取字型大小偏好

    (1)@property(nonatomic, readonly) NSString *preferredContentSizeCategory  :使用者更加喜歡的字型大小選擇

19.管理預設的介面方向

    (1)- (UIInterfaceOrientationMask)supportedInterfaceOrientationsForWindow:(UIWindow *)window  :返回指定視窗支援的介面方向

20.管理狀態列的方向

    (1)@property(nonatomic, readonly) NSTimeInterval statusBarOrientationAnimationDuration  :當裝置90度轉變的時候狀態列的動畫轉換

21.資料類型

    (1)UIStatusBarStyle類型

UIStatusBarStyleDefault,  :黑色的狀態列

UIStatusBarStyleLightContent,  :光亮的狀態列

UIStatusBarStyleBlackTranslucent,  :黑色透明的狀態列

UIStatusBarStyleBlackOpaque  :黑色不透明的狀態列

    (2)UIStatusBarAnimation類型

UIStatusBarAnimationNone,  :狀態列顯示和隱藏的時候沒有動畫

UIStatusBarAnimationFade,  :狀態列顯示和隱藏的時候使用漸隱漸現的動畫

UIStatusBarAnimationSlide,  :狀態列顯示和隱藏的時候使用滑動的動畫

22.常量    (1)UIApplicationState常量UIApplicationStateActive,  :app正在前端運行並且接受事件UIApplicationStateInactive,  :app正在前端運行但不接受事件 UIApplicationStateBackground    :app正在後台運行    (2)Background Task Constants常量const UIBackgroundTaskIdentifier UIBackgroundTaskInvalid;  :這個常量應該用來初始化一個常量或者檢查一個錯誤const NSTimeInterval UIMinimumKeepAliveTimeout;  :app應該在後台啟動並執行時間

    (3)UIBackgroundFetchResult常量

UIBackgroundFetchResultNewData,  :新的資料成功載入

UIBackgroundFetchResultNoData,  :沒有新的資料可以載入

UIBackgroundFetchResultFailed  :資料載入失敗

23.通知

    (1)UIApplicationBackgroundRefreshStatusDidChangeNotification  :當backgroundRefreshStatus屬性的值發生變化的時候就會發送這個通知

    (2)UIApplicationDidBecomeActiveNotification  :當app將要成為活躍狀態的時候就會發送這個通知

    (3)UIApplicationDidChangeStatusBarFrameNotification  :當狀態列的frame發生改變結束的時候就會發送這個通知

    (4)UIApplicationDidChangeStatusBarOrientationNotification  :當app的使用者介面的方向發生改變的時候就會發送這個通知

    (5)UIApplicationDidEnterBackgroundNotification  :當app進行背景時候就會發送這個通知

    (6)UIApplicationDidFinishLaunchingNotification  :當app結束啟動的時候就會發送這個通知

    (7)UIApplicationDidReceiveMemoryWarningNotification  :當可用運行記憶體不足的時候就會發送這個通知

    (8)UIApplicationProtectedDataDidBecomeAvailable  :當受保護的檔案已經可以被使用的時候就會發送這個通知

    (9)UIApplicationProtectedDataWillBecomeUnavailable  :當受保護的檔案被鎖住變得不可以使用的時候就會發送這個通知

    (10)UIApplicationSignificantTimeChangeNotification  :當有重大的時間發生改變的時候就會發送這個通知,如改變到新的一天

    (11)UIApplicationUserDidTakeScreenshotNotification  :當按下home鍵和按鈕來的時候就會發送這個通知

    (12)UIApplicationWillChangeStatusBarOrientationNotification  :當app改變了介面的方向的時候就會發送這個通知

    (13)UIApplicationWillChangeStatusBarFrameNotification  :當狀態列的frame開始發生改變的時候就會發送這個通知

    (14)UIApplicationWillEnterForegroundNotification  :當app將要從後台活躍到前端的時候就會發送這個通知

    (15)UIApplicationWillResignActiveNotification  :當app不再活躍或者失去關注的時候就會發送這個通知

    (16)UIApplicationWillTerminateNotification  :當app要終止的時候就會發送這個通知

    (17)UIContentSizeCategoryDidChangeNotification  :當使用者改變設定的內容大小的時候就會發送這個通知

 

    

UIkit架構之uiUIapplication

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.