iOSAPP前台后台切换的处理
来源:互联网 发布:java aes 256 cbc 编辑:程序博客网 时间:2024/06/15 23:22
对于APP前后台切换的监听,大家所熟知的就是,在AppDelegate中实现下面两个方法,能够监听从后台恢复到前台
- (void)applicationDidEnterBackground:(UIApplication *)application { log4info(@"---applicationDidEnterBackground----"); //进入后台 } - (void)applicationDidBecomeActive:(UIApplication *)application { NSLog(@"---applicationDidBecomeActive----"); //进入前台 } - (void)applicationDidEnterBackground:(UIApplication *)application{ log4info(@"---applicationDidEnterBackground----"); //进入后台}- (void)applicationDidBecomeActive:(UIApplication *)application{ NSLog(@"---applicationDidBecomeActive----"); //进入前台 }
但是单个UIViewController怎么监听呢
在-viewDidLoad方法中,添加一下代码监听notification
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(someMethod:) name:UIApplicationDidBecomeActiveNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(someMethod:) name:UIApplicationDidBecomeActiveNotification object:nil];
别忘了在-dealloc中将监听移除:
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self];
0 0
- iOSAPP前台后台切换的处理
- android 监听后台到前台的切换
- Linux前台和后台任务的切换
- 前台、后台进程切换
- 后台和前台对json的处理
- iOSAPP 增加后台处理机制送审注意问题
- Linux程序前台后台切换
- Linux程序前台后台切换
- 关于activity前台后台切换
- Linux程序前台后台切换
- Linux程序前台后台切换
- Linux程序前台后台切换
- Linux程序前台后台切换
- Linux程序前台后台切换
- Android 监听前台后台切换
- linux 进程前台/后台切换
- 【WPF】后台切换前台图片
- 将后台运行的VMWare切换到前台
- 蓝屏代码大全
- ArrayList和Vector以及synchronizedList
- SCORM标准及支持SCORM标准学习平台的设计
- Android开发之-- 利用百度sdk实现在app中提示其更新
- 2个DIV切换显示
- iOSAPP前台后台切换的处理
- Lua IO库详解
- jQuery六章 使用jQuery操作DOM
- react-native Linking
- poj1175 搜索+hash
- 浅谈JDBC的升级之路
- Usb otg storage 的调试
- nginx php显示空白处理
- Linux 网络接口配置(/etc/network/interfaces)