iOS学习笔记01-APP相关
tluhb
9年前
<h3>AppDelegate对象方法</h3> <pre> <code class="language-objectivec"># 程序第一次启动后才会执行 - (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;</code></pre> <p><img alt="iOS学习笔记01-APP相关" src="https://simg.open-open.com/show/8321590a67ec50ba0084cee512e47288.png" width="330" height="392"></p> <p>APP启动加载</p> <pre> <code class="language-objectivec">- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // 设置window属性(iOS应用必须有一个主窗口UIWindow),初始化windows的大小和位置 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // 设置window的背景 self.window.backgroundColor = [UIColor whiteColor]; // 初始化KCMainViewController KCMainViewController *mainController = [[KCMainViewController alloc]init]; // 设置自定义控制器的大小和window相同,位置为(0,0) mainController.view.frame = self.window.bounds; // 设置此控制器为window的根控制器,UIWindown必须有根控制器 self.window.rootViewController = mainController; // 设置window为应用程序主窗口并设为可见 [self.window makeKeyAndVisible]; return YES; }</code></pre> <h3>UIApplication常用属性和方法</h3> <pre> <code class="language-objectivec"># 属性 // 显示应用图标右上角数字 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"]];</code></pre> <p>来源:http://www.cnblogs.com/liutingIOS/p/5351508.html </p>