iOS--UINavigationController学习笔记二
来源:互联网 发布:淘宝卖家中心在哪 编辑:程序博客网 时间:2024/06/12 19:35
1.定制statusBar的新发现
前面提到过,将View controller-based status bar appearance设为YES,通过设置UINavigationBar.barStyle来改变statusBar的状态。这样有一点不好的地方在于,通常在viewController里面改变这一属性的值是影响到全局的,一般在viewController消失之前会复原。但是,这几天在看果爹的api,发现ViewController里面有这么两个方法
- (nullableUIViewController*)childViewControllerForStatusBarStyleNS_AVAILABLE_IOS(7_0)__TVOS_PROHIBITED;
- (nullableUIViewController*)childViewControllerForStatusBarHiddenNS_AVAILABLE_IOS(7_0)__TVOS_PROHIBITED;
官方的解释是说:如果这两个方法返回的是nil,在setNeedsStatusBarAppearanceUpdate方法调用之后,会调用自己的prefferedStatusBarStyle 和prefferedStatusBarHidden 方法,如果返回的是自己的childViewController,就是调用childViewController的prefferedStatusBarStyle 和prefferedStatusBarHidden 方法。这样,可以想到,设计一个UINavigationController的子类,复写上面的两个方法,统一返回UINavigationController.topViewController,这样每个UINavigationController栈中viewController,可以直接在prefferedStatusBarStyle 和prefferedStatusBarHidden方法中进行控制了。而且是不需要进行复原控制的。
这种方法前提:是将View controller-based status bar appearance设为YES。
2.UINavigationControllerDelegate学习一
UINavigationController提供了一个delegate,作用是可以全局定制一些导航栏的相关设置(最常见的就是统一定制导航栏顶部的返回样式),以及UINavigationController在进行push和pop的动画控制,现在好多文章都解释为转场动画,就是下一个场景(scene)viewController的view替代当前场景的viewController的view的动画。
该delegate里面先是定义了下面两个方法:从方法名可以理解是在viewController将要显示时进行的调用。
- (void)navigationController:(UINavigationController*)navigationController willShowViewController:(UIViewController*)viewController animated:(BOOL)animated;
- (void)navigationController:(UINavigationController*)navigationController didShowViewController:(UIViewController*)viewController animated:(BOOL)animated;
那么,在UIViewController的显示生命周期中的哪个阶段进行调用的呢?通过Demo写代码,打Log得出的一个截图
可以得出willShowViewController是在willAppear之后,didShowViewController是在didAppear之后进行调用的
0 0
- iOS--UINavigationController学习笔记二
- iOS--UINavigationController学习笔记
- iOS--UINavigationController学习笔记三
- iOS-UINavigationController的学习
- iOS 笔记二:Multiple MVCs 、UINavigationController 、UITabBarController
- ios-UINavigationController 详解
- IOS学习笔记13—UINavigationController
- IOS学习笔记(5)UINavigationController UITabBarController
- iOS学习笔记-7 UINavigationController定制
- IOS学习笔记(5)UINavigationController UITabBarController
- iOS Programming 学习笔记 - 05 UINavigationController
- iOS学习笔记(6)UINavigationController
- ios客户端学习-AppDelegate获取UINavigationController及UIStoryboard
- iOS学习之UINavigationController详解与使用(二)
- ios学习:UINavigationController导航
- ios学习:UINavigationController导航
- IOS学习之UINavigationController
- UINavigationController学习笔记
- 五.服务器提高性能的建议
- Timus 1330. Intervals
- Uva 12096 The SetStack Computer
- 读芥川龙之介小说
- dlopen example
- iOS--UINavigationController学习笔记二
- EntityFramework错误处理
- 素数筛法
- 关于Android 添加系统级(java)服务和调用的编写实现说明
- hdu 1269 迷宫城堡 强连通分量分解
- String和string区别
- Python 基础 —— from __future__ import
- Java 中的反射
- 在mac上使用VMware Fusion安装windows连不上网问题