动态加载storyBoards

shi*_*yuX 4 objective-c ios uistoryboard

我正在开发一个storyBoard加载系统,我需要检查特定storyBoard的存在.

我做了一个函数检查它(给定一个特定的StoryBoard名称):

(NSString *)ressourceNameForDevice:(NSString *)rootName extension:(NSString *)ext
{
    NSString *retString = rootName;
    NSString *iPadString = [NSString stringWithFormat:@"%@-iPad", rootName];
    NSString *iPhoneWideString = [NSString stringWithFormat:@"%@-wide", rootName];

    if (IS_IPAD &&
        (nil != [[NSBundle mainBundle] pathForResource:iPadString ofType:ext]))
    {
        retString = iPadString;
    }

    if (IS_IPHONE_WIDE &&
        (nil != [[NSBundle mainBundle] pathForResource:iPhoneWideString ofType:ext]))
    {
        retString = iPhoneWideString;
    }

    return retString;
}
Run Code Online (Sandbox Code Playgroud)

我用@"storyboard"扩展参数调用这个函数.

我probleme是函数调用失败上nil != [[NSBundle mainBundle] pathForResource:iPhoneWideString ofType:ext],尽管故事板IS目前在我的项目和捆绑,它不会发现.我想我应该给它另一个扩展,我也试过@"nib"但没有更多的结果.

谁知道怎么检查?

shi*_*yuX 6

解决了它.问题是,一旦storyBoard被编译,ressource扩展不是,.storyboard但编译文件具有扩展名的.storyboardc方式相同..xib.nib