AppDelegate物件方法
# 程式第一次啟動後才會執行
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
# 程式將要失去焦點時執行
- (void)applicationWillResignActive:(UIApplication *)application;
# 程式得到焦點時呼叫
- (void)applicationDidBecomeActive:(UIApplication *)application;
# 程式進入後臺執行
- (void)applicationDidEnterBackground:(UIApplication *)application;
# 程式進入前臺執行
- (void)applicationDidEnterForeground:(UIApplication *)application;
# 程式即將退出時呼叫
- (void)applicationWillTerminate:(UIApplication *)application;
# 程式發生記憶體警告的時候呼叫
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application;
複製程式碼
APP啟動載入
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
KCMainViewController *mainController = [[KCMainViewController alloc]init];
mainController.view.frame = self.window.bounds;
self.window.rootViewController = mainController;
[self.window makeKeyAndVisible];
return YES;
}
複製程式碼
UIApplication常用屬性和方法
# 屬性
application.applicationBadgeNumber = 8;
application.statusBarStyle = UIStatusBarStyleBlackOpaque;
application.statusBarHidden = YES;
application.networkActivityIndicatorVisible = YES;
# 方法
[application openURL:[NSURL urlWithString:@"http://www.baidu.com"]];
[application openURL:[NSURL urlWithString:@"tel://xxxxxxxxx"]];
[application openURL:[NSURL urlWithString:@"sms://xxxxxxxxx"]];
複製程式碼