如何知道当前的故事板名称? [英] How to know the current storyboard name?

查看:83
本文介绍了如何知道当前的故事板名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道当前加载的故事板是什么,我使用下面的代码,但它仍然是我的主故事板而不是当前。

I want to know what is the current loaded storyboard,I used the below code but it is still get me the Main storyboard not the current.

//This get me the Main storyboard 
[[NSBundle mainBundle].infoDictionary objectForKey:@"UIMainStoryboardFile"];


推荐答案

如果您正在使用即时的UIViewController类或通过故事板进行细分最简单的方法是:

If you are working in a UIViewController class that is instantied or segues through the storyboard the most simple way is :

UIStoryboard *storyBoard = self.storyboard;

如果你在UIViewController中的UIView类

If you are in a UIView class that is in a UIViewController

UIResponder *responder = self;
while (![responder isKindOfClass:[UIViewController class]]) {
    responder = [responder nextResponder];
    if (nil == responder) {
        break;
    }
}
UIViewController *viewController = (UIViewController *) responder;
UIStoryboard *storyBoard = viewController.storyboard;

这篇关于如何知道当前的故事板名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆