无法在捆绑中加载NIB

时间:2015-04-16 22:22:56

标签: ios objective-c cocoapods nib nsbundle

据我所知,还有其他与此问题非常类似的问题,但似乎没有任何帮助我。

我通过cocoapods包含一个库,其中包含一个带有.xib文件的资源包。当我从该库调用一个方法时,会调用它:

dispatch_once(&pred,
              ^{
                  NSBundle *posBundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"ClipPOSLibrary" ofType:@"bundle"]];
                  sharedInstance = (POSReaderAlert*)[posBundle loadNibNamed:@"POSReaderAlert" owner:self options:nil][0];
                  sharedInstance.yCenterOffsetPercentage = 0;
                  sharedInstance.batteryThresholds = @[@(1), @(5), @(10), @(20)];
                  sharedInstance.currentThreshold = 3;
                  [[NSNotificationCenter defaultCenter] addObserver:sharedInstance
                                                           selector:@selector(handleRotation:)
                                                               name:UIApplicationDidChangeStatusBarOrientationNotification
                                                             object:nil];
              });

我在'sharedInstance =(POSReder .....'行)上遇到抛出异常。这是例外:

Could not load NIB in bundle: 'NSBundle </var/mobile/Containers/Bundle/Application/F41CE11A-1E7A-4902-83F2-285CC2508D41/EMV-Flow-Example.app/ClipPOSLibrary.bundle> (not yet loaded)' with name 'POSReaderAlert'

我确保在构建库时,nib选择了正确的目标,并且它包含在所需的任何位置。奇怪的是,我并不总是得到这个错误。我用相同的库建立了项目,一切似乎都运行良好,但在其他项目中却没有。所以我的猜测是,我在项目配置/设置中做错了但我真的无法弄清楚是什么。

非常感谢您的帮助!

*更新* 所以我通过修复目标设置来使用一个好的xcconfig文件来解决iOS 6和7的问题,这需要完成,因为工作区有点不稳定,里面有三个不同的项目。但问题仍然发生在iOS 8上。任何想法?

0 个答案:

没有答案
相关问题