我已经成功收录了来自的Phonegap Plugin Barcodescanner Github iOS Phonegap Plugins
扫描方法有效。我在没有自定义XIB文件的情况下测试了它。它在iPad和iPhone上都显示了很好的叠加效果。
window.plugins.barcodeScanner.scan(success, fail)
除了显示我按照说明逐步遵循的自定义XIB
window.plugins.barcodeScanner.scan(success, fail, ["BarcodeOverlay"])
但我面临一个问题: 我的自定义XIB在iPad或iPhone上都很奇怪。 是否有人知道插件如何使用标准XIB处理此问题?
答案 0 :(得分:2)
仅供参考 - 通过自定义CDVBarcodeScanner.mm类解决方法,方法buildOverlayFromXib
- (UIView *)buildOverlayViewFromXib
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
// iPad-specific interface here
self.alternateXib = @"BarcodeOverlay_iPad";
[[NSBundle mainBundle] loadNibNamed:self.alternateXib owner:self options:NULL];
}
else if (IS_IPHONE_5) {
self.alternateXib = @"BarcodeOverlay_iPhone5";
[[NSBundle mainBundle] loadNibNamed:self.alternateXib owner:self options:NULL];
}
else
{
// iPhone and iPod touch interface here
self.alternateXib = @"BarcodeOverlay_iPhone";
[[NSBundle mainBundle] loadNibNamed:self.alternateXib owner:self options:NULL];
}
if ( self.overlayView == nil )
{
NSLog(@"%@", @"An error occurred loading the overlay xib. It appears that the overlayView outlet is not set.");
return nil;
}
return self.overlayView;
}