iOS Dev (39) 你明白 UIApplicationDelegate 吗?
几个方法
application:didFinishLaunchingWithOptions:
applicationWillResignActive:
applicationDidBecomeActive:
applicationWillEnterBackground:
applicationWillEnterForeground:
applicationDidReceiveMemoryWarning:
application:didFinishLaunchingWithOptions
UIApplication 被实例化后第一个触发的协议方法,就是这货。这货主要的任务,就是创建一个 UIWindow,在这货上面显示控制器的视图。
applicationWillResignActive:
应用从 Active 变为 Inactive 时,触发该协议方法。比如有电话打来时。
applicationDidBecomeActive
应用从 Inactive 变为 Active 时,触发该协议方法。
applicationWillEnterBackground:
应用切换至后台时,触发该协议方法。
applicationWillEnterForeground:
应用切换至前台时,触发该协议方法。
applicationDidReceiveMemoryWarning:
设备内存不足时,会触发该协议方法。这里我自己有一个疑问:Background 时也触发吗?
如果应用执行了这个方法后,系统还是没有足够的内存,系统就有可能 kill 这个应用。
如果想主动获取 AppDelegate 怎么办?
[[UIApplication sharedApplication] delegate]
哈哈,简单吧。
转载请注明来自大锐哥的博客:http://blog.csdn.net/prevention
分享到:
相关推荐
The UIApplicationDelegate protocol declares methods that are implemented by the delegate of the singleton UIApplication object. These methods provide you with information about key events in an ...
iOS4的入门书籍 1 The iOS Software Development Kit (SDK) 2 A C Refresher 3 Just Enough Objective-C: Part One 4 Just Enough Objective-C: Part Two 5 Deploying to an iPhone, Debugging, and Testing 6 ...
@interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end // // AppDelegate.m // Hello World_Code // #import "AppDelegate.h" @...
iOS 12 CarPlay示例在iOS 12及更高版本中使用CarPlay框架的示例。概括该示例项目使用CarPlay框架从您现有的项目开始一个简单的导航会话。 它利用CPApplicationDelegate连接到您的汽车, CPInterfaceController附加您...
您想知道什么很乏味吗? 如果没有正确的工具,则调试网络请求和响应。 Guppy是一个专注于HTTP请求的...class AppDelegate : UIResponder , UIApplicationDelegate { var window: UIWindow ? func application ( _ ap
在Swift中实现Model View Controller模式的iOS应用程序模板。 iOS具有其特点:应用程序界面由单独的屏幕(场景)组成,这就是为什么它具有情节提要功能的原因。 有一个UIViewController类看起来像MVC模式中的控制器...
PangoPay SDK 一个用于连接到PangoPay API的SDK。...配置客户端的最佳位置是iOS上的+[UIApplicationDelegate didFinishLaunchingWithOptions] 。 在那里你可以打电话 [[PangoPayDataCacher sharedInstance]
轻松将Google Analytics(分析)集成到您的iOS,macOS和tvOS应用中,而无需下载任何Google SDK。 重要通知: Google正式取消了通过Google Analytics(分析)进行移动分析跟踪的选项。 要求新应用使用Firebase。 ...
本文实例为大家分享了IOS网络嗅探工具,供大家参考,具体内容如下 一、效果图 二、工程图 三、代码 AppDelegate.h #import #import Reachability.h @interface AppDelegate : UIResponder ...
SQLite.viewer 一个优雅的库,用于在iOS应用程序中查看,编辑或调试sqlite数据库。 受启发。特征列出可用的数据库列表表运行原始查询去做 插入行 编辑行 删除行 新的用户界面和用户体验用法在AppDelegate.swift文件...
UIApplicationDelegate提供了两种方法,可在用户打开应用程序时用来运行代码: applicationWillEnterForeground和applicationDidBecomeActive 。 但是以下两种方法都不适合这种情况: 首次启动应用程序时未调用...
要求:iOS 9.0+•Swift 5.0+基本用法在您的AppDelegate中: import SMLocalize@UIApplicationMainclass AppDelegate : UIResponder , UIApplicationDelegate , ReloadableAppDelegate { var window : UIWindow ?...
为iOS 11编写的Uber克隆应用程序。模仿Uber的许多功能,以了解源代码以及如何实现各种功能。 了解与Firebase服务器进行交互,通过通知和地理地图功能在用户和驱动程序之间进行通信。 安装和构建应用程序的步骤 在...
CVKHierarchySearcher 是一个小型实用程序类,用于遍历 iOS 应用程序的视图控制器层次结构并检索经常需要的最顶层视图控制器。 现在它提供了最顶层、最顶层的非模态和最顶层的UINavigationController 。 用法 使用...
在使用iOS推送时,出现下面错误: **[1412:60b] You've implemented -[<UIApplicationDelegate> application:performFetchWithCompletionHandler:], but you still need to add fetch to the list of your ...
var appDelegate: UIApplicationDelegate { get } UIApplication public func setStatusBarBackgroundColor ( _ color : UIColor) UIImageView public func colored ( color : UIColor ? ) UISlider public ...
定位和位置信息获取 定位和反查位置信息要加载两个动态库 CoreLocation.framework 和 MapKit.framework 一个获取坐标一个提供反查 ...UIApplicationDelegate,CLLocationManagerDelegate,MKReverseGeocoder
@interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end #import AppDelegate.h #import RootViewController.h @interface AppDelegate () @end @...
不再疯狂, Contract让你更容易签下你的灵魂。用法 import UIKit@UIApplicationMainclass AppDelegate : UIResponder , UIApplicationDelegate , HYPContractViewControllerDelegate { var window: UIWindow ? func...