IOS4多任务下,viewWillAppear不能调用的问题解决 (转)
2011-12-13 13:18
543 查看
问题描述:原来在IOS3里面通过viewWillAppear来初始化画面数据,但是升级到IOS4后,在画面显示时直接按【home】键退出,再次进入时,画面并没有初始化最新的数据。
解决办法:添加下面代码
C代码
- (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, called instead of applicationWillTerminate: when the user quits.
*/
[viewController.modalViewController viewWillDisappear:NO];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
*/
[viewController.modalViewController viewWillAppear:NO];
}
原因分析:由于IOS4支持多任务,应用程序按【home】是只是转到当前活动应用的后面,并没有退出,相当于画面暂停了,这里在程序转到后面时强制运行viewWillDisappear方法,返回活动应用时强制运行viewWillAppea
解决办法:添加下面代码
C代码
- (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, called instead of applicationWillTerminate: when the user quits.
*/
[viewController.modalViewController viewWillDisappear:NO];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
*/
[viewController.modalViewController viewWillAppear:NO];
}
- (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, called instead of applicationWillTerminate: when the user quits. */ [viewController.modalViewController viewWillDisappear:NO]; } - (void)applicationWillEnterForeground:(UIApplication *)application { /* Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. */ [viewController.modalViewController viewWillAppear:NO]; }
原因分析:由于IOS4支持多任务,应用程序按【home】是只是转到当前活动应用的后面,并没有退出,相当于画面暂停了,这里在程序转到后面时强制运行viewWillDisappear方法,返回活动应用时强制运行viewWillAppea
相关文章推荐
- iOS CAlayer 动画进入后台或者 调用viewWillDisappear viewDidDisappear后动画暂停问题的解决办法
- 解决:IOS viewDidAppear/viewWillAppear无法被调用
- navigationController中viewWillAppear,viewDidAppear,viewWillDisappear和viewDidDisappeart调用问题
- iOS 当前视图控制器view.frame 在viewDidLoad 和 viewWillAppear 中值不一样问题
- iPhone开发之解决viewWillAppear不被调用
- iPhone开发之解决viewWillAppear不被调用
- android中webView加载H5,JS不能调用问题的解决
- viewWillDisappear,viewWillAppear不调用的解决方法
- IOS开发问题解决之UIAlertView调用UIActionSheet后灰色背景一直存在
- iPhone开发之解决viewWillAppear不被调用
- different addSubview behavior between iOS 4.3 and 5.0(viewWillAppear 不被调用)
- viewWillDisappear,viewWillAppear不调用的解决方法
- addChildViewController后 Childvc viewWillAppear 不调用的问题
- 猫猫学iOS 之控制器view显示中view的父子关系及controller的父子关系_解决屏幕旋转不能传递事件问题
- addChildViewController后 Childvc viewWillAppear 不调用的问题
- iOS 之控制器view显示中view的父子关系及controller的父子关系_解决屏幕旋转不能传递事件问题
- webView加载Html5按钮,JS不能调用问题的解决
- ios 4.3 中 viewDidAppear没有被调用的解决办法
- 关于IOS开发中addSubView上去的viewController的viewWillAppear 和viewDidAppear 等调用的总结
- ios开发 解决ios6中UIScrollView不能滚动的问题