IOS AppDelegate介绍

本文深入探讨了iOS开发中的Swift编程语言,分享了实用的编程技巧和最佳实践,帮助开发者提高开发效率并创建高质量的应用程序。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

@interface ownmoneyAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end

window为当前应用显示窗口。

#import "AppDelegate.h"
#import "HomeViewController.h"
#import "BandViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    //覆盖后,应用程序启动定制即决定App初始化显示内容
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    //使用Storyboard初始化根界面
    UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
//    self.window.rootViewController = [storyBoard instantiateInitialViewController];
//    HomeViewController *home = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
    HomeViewController *home = [storyBoard instantiateViewControllerWithIdentifier:@"HomeViewController"];
    BandViewController *nav = [[BandViewController alloc] initWithRootViewController:home];
    self.window.rootViewController = nav;
    [self.window makeKeyAndVisible];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.                                                                                                             //当应用程序即将从活动转移到非活动状态时发送。这可能会发生某些类型的临时中断(例如呼入电话呼叫或SMS消息),或者当用户退出该应用程序和它开始过渡到背景状态。
    //使用这个方法来暂停正在进行的工作,关闭计时器,并踩下油门的OpenGL ES的帧速率。游戏应该使用这种方法来暂停游戏。
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.                                                                                                                           //使用这个方法来释放共享资源,保存用户数据,无效计时器,并储存足够的应用程序状态信息到你的应用程序恢复到其当前状态的情况下,它后来终止。
    //如果您的应用程序支持后台运行,这种方法被称为代替applicationWillTerminate:当用户退出。
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.                                                                                                           //调用作为从背景到非活动状态的转换的一部分;在这里您可以撤消许多就进入后台的变化。
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.                                                                      //重新启动被暂停的(或尚未开始),而应用程序是不活动的任何任务。如果该应用程序是以前的背景,任选刷新用户界面。
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.        //当应用程序即将终止调用。如果适当保存数据。另请参见applicationDidEnterBackground:.
}

@end


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值