我有成功地包括了Github iOS Phonegap插件的Phonegap插件Barcodescanner。
扫描方法有效。我在没有自定义XIB文件的情况下测试了它。它在iPad和iPhone上都显示了一个很好的覆盖。
window.plugins.barcodeScanner.scan(success, fail)以及显示一个自定义的XIB,我已经一步一步地遵循了说明。
window.plugins.barcodeScanner.scan(success, fail, ["BarcodeOverlay"])但我面临一个问题:无论是在iPad上还是在iPhone上,我的定制XIB看起来都很奇怪。,有人知道插件是如何用标准的XIB?来处理这个问题的吗?
发布于 2013-08-16 09:07:21
通过自定义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; }
https://stackoverflow.com/questions/15308565
复制相似问题