我正在开发一个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;
}
我正在使用
@"storyboard"
作为扩展参数调用此函数。我的问题是,即使故事板在我的项目和包中存在,函数在
nil != [[NSBundle mainBundle] pathForResource:iPhoneWideString ofType:ext]
行失败,它仍然无法被找到。我猜我应该给它另一个扩展名,我也尝试过使用@"nib"
,但没有更多的结果。有人知道如何检查这个吗?
[UIStoryboard storyboardWithName:@"xxx" bundle:nil]
呢? - Larme@"xxx"
部分,因为对于_Hello.storyboard_,有一个_Hello-wide.storyboard_和一个_Hello-iPad.storyboard_。 - shinyuX