Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在原来的代码中使用到self.navigationController.viewControllers #13

Closed
swsdyg opened this issue Jul 13, 2016 · 7 comments
Closed

Comments

@swsdyg
Copy link

swsdyg commented Jul 13, 2016

@rickytan 你好,我在原来的代码中使用到self.navigationController.viewControllers;直接使用您的这个项目好像会出问题,self.navigationController.viewControllers;返回的数组中正常情况下只会包含当前的vc,是不是需要重写一下viewControllers的getter方法,谢谢回答!

@rickytan
Copy link
Owner

是什么情况下需要直接用这个?你可以:

self.rt_navigationController.rt_viewControllers;

重写 getter 尚不清楚会不会造成隐患

@swsdyg
Copy link
Author

swsdyg commented Jul 13, 2016

其实我也注意到了,重写getter确实容易造成问题,我看了您的源码,我准备再封装一层然后使用self.rt_navigationController.rt_viewControllers,我还想问一个问题,就是我在viewcontroller(不是navigationcontroller)的子类中重写了- (UIStatusBarStyle)preferredStatusBarStyle方法,但是不会调用,但我看您的调用没问题,不知您知道是什么原因吗,还望不吝赐教!

@rickytan
Copy link
Owner

你的 viewController 子类放在哪个里面?

@swsdyg
Copy link
Author

swsdyg commented Jul 14, 2016

我是说你在RTContainerController类中重写了- (UIStatusBarStyle)preferredStatusBarStyle方法会调用,而我自己写了一个UIViewController的子类,里面也重写了该方法但不会调用(我的工程还没引入您的项目,我只是单纯的请教问题,希望您不要见谅),我一直不明白原因,所以想请教一下。
截图是您的代码,这个方法是会自动调用的
screen shot 2016-07-14 at 11 08 00 am
下面是我的代码,但该方法不会被调用
screen shot 2016-07-14 at 11 14 57 am

screen shot 2016-07-14 at 11 14 08 am

@rickytan
Copy link
Owner

  1. Info.plist 中设置 view controller based status bar 为 YES
  2. 如果你的 VC 在系统的 Navigation 中,它不会被调到,Navigation 接管了

@swsdyg
Copy link
Author

swsdyg commented Jul 15, 2016

@rickytan 谢谢你,我找到原因了,其实你的根本没有设置view controller based status bar 为 YES
但你的RTContainerController中的- (UIStatusBarStyle)preferredStatusBarStyle方法会调用,是因为你的navigation bar是隐藏的,我实验了一下,如果我把自己写的navigation bar隐藏掉也是可以的,谢谢你!
be6c86c7-2ce9-4314-a957-aeb80495ce88

@rickytan
Copy link
Owner

参考 #9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants