ios应用UIApplication前后台切换代理方法在不同ios系统下的差异
2013-01-11 17:46
489 查看
对于一个完善的应用来说,需要在UIApplication的各个代理方法里进行相应的处理,特别是前后台切换时一般需要进行一些特定的操作;而对于不同版本的ios系统,其代理方法居然也存在着一些差异,不由得让人大跌眼镜。
IOS4:
IOS5及以后:
可以看到,ios4的锁屏和解锁不会触发didenterbackground方法和willenterforeground方法;而ios5中的didenterbackground方法通过UIApplicationState state = [[UIApplication sharedApplication] applicationState]可以区分是由按home触发还是按锁屏键触发;锁屏时状态为inactive,home键为background.而在willresignactive方法中,两种行为的state均为active。从个人的使用上来看,通过didenterbackground中的state可以很好的在实现上加以区分以实现相异的行为,而在4x系统下就比较麻烦,只能从流程上打主意,不利于实现。
IOS4:
// Pressing the home button Will resign active. Did enter background. // Tapping app icon on Springboard Will enter foreground. Did become active. // Pressing the lock button Will resign active. // Unlocking the device Did become active.
IOS5及以后:
// Pressing the home button Will resign active. Did enter background. // Tapping app icon on Springboard Will enter foreground. Did become active. // Pressing the lock button Will resign active. Did enter background. // Unlocking the device Will enter foreground. Did become active.
可以看到,ios4的锁屏和解锁不会触发didenterbackground方法和willenterforeground方法;而ios5中的didenterbackground方法通过UIApplicationState state = [[UIApplication sharedApplication] applicationState]可以区分是由按home触发还是按锁屏键触发;锁屏时状态为inactive,home键为background.而在willresignactive方法中,两种行为的state均为active。从个人的使用上来看,通过didenterbackground中的state可以很好的在实现上加以区分以实现相异的行为,而在4x系统下就比较麻烦,只能从流程上打主意,不利于实现。
相关文章推荐
- iOS应用程序生命周期(前后台切换,应用的各种状态)详解
- iOS应用程序生命周期(前后台切换,应用的各种状态)详解
- 让iOS应用支持不同版本的系统与设备
- iOS应用程序生命周期(前后台切换,应用的各种状态)详解
- iOS用WKWebView与JS交互获取系统图片及WKWebView的Alert,Confirm,TextInput的监听代理方法使用,屏蔽WebView的可选菜单
- iOS 去掉导航左侧按钮系统默认的文字 只留 默认箭头 (而且解决了 切换应用是 闪桌面的问题)
- iOS应用内部切换语言,不跟随系统
- iOS应用程序生命周期(前后台切换,应用的各种状态)详解
- iOS应用程序生命周期(前后台切换,应用的各种状态)详解
- iOS应用程序生命周期(前后台切换,应用的各种状态)详解
- iOS应用程序生命周期(前后台切换,应用的各种状态)详解
- iOS应用程序生命周期(前后台切换,应用的各种状态)详解
- iOS应用程序生命周期(前后台切换,应用的各种状态)详解
- iOS应用程序生命周期(前后台切换,应用的各种状态)详解
- [转]iOS应用程序生命周期(前后台切换,应用的各种状态)详解
- iOS 应用从后台关闭调用的方法
- iOS应用程序生命周期(前后台切换,应用的各种状态)详解
- iOS应用程序生命周期(前后台切换,应用的各种状态)详解
- iOS应用程序生命周期(前后台切换,应用的各种状态)详解 .