【问题标题】:Phonegap Barcodescanner Plugin - custom XIB for both iPad and iPhonePhonegap Barcodescanner Plugin - 适用于 iPad 和 iPhone 的自定义 XIB
【发布时间】:2013-03-09 08:00:01
【问题描述】:

我已成功包含了 Phonegap 插件 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 处理这个问题?

【问题讨论】:

  • 哪里有关于如何使用自定义 XIB 的说明?

标签: ios cordova phonegap-plugins


【解决方案1】:

仅供参考 - 通过自定义 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;        

}

【讨论】:

    猜你喜欢
    • 2012-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多