小编Tho*_*son的帖子

Xcode AVCapturesession扫描特定帧中的条形码(rectOfInterest不工作​​)

我正在尝试为我正在使用的App设计条形码扫描仪.我希望扫描仪预览能够填满设备的整个屏幕,并提供一个较小的框架来指向条形码.所有的工作都是我想要的,但我不能让感兴趣的框架工作.

这是条形码扫描仪的实现:

#import "GEScannerViewController.h"
@import AVFoundation;

@interface GEScannerViewController () <AVCaptureMetadataOutputObjectsDelegate> {
    AVCaptureSession *_session;
    AVCaptureDevice *_device;
    AVCaptureDeviceInput *_input;
    AVCaptureMetadataOutput *_output;
    AVCaptureVideoPreviewLayer *_prevLayer;

    UIView *_greyView;
    UIView *_highlightView;
    UIView *_scopeView;
    UILabel *_label;
}
@end

@implementation GEScannerViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    _label = [[UILabel alloc] init];
    _label.frame = CGRectMake(0, self.view.bounds.size.height - 40, self.view.bounds.size.width, 40);
    _label.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
    _label.backgroundColor = [UIColor colorWithWhite:0.15 alpha:0.65];
    _label.textColor = [UIColor whiteColor];
    _label.textAlignment = NSTextAlignmentCenter;
    _label.text = @"(none)";
    [self.view addSubview:_label];

    NSError *error = nil;

    _session = [[AVCaptureSession alloc] init]; …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c barcode-scanner ios avmetadataitem

2
推荐指数
1
解决办法
5210
查看次数

Swift 3-为什么我的导航栏不显示?

我有一个简单的应用程序,用于测试其余api的推送通知。我想在应用程序中显示导航栏,但是它不起作用。在我的AppDelegate中,我有以下代码:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    self.registerForPushNotifications()
    let url = "dev"
    UserDefaults.standard.setValue(FFHelper.url(slug: url.slug()), forKey: "api-url")
    var vcString = "loginView"
    if KeychainSwift().get("auth-token") != nil {
        vcString = "notificationsTable"
    }
    let initialVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: vcString)
    initialVC.navigationController?.navigationBar.isHidden = false
    initialVC.navigationController?.setNavigationBarHidden(false, animated: true)
    window?.rootViewController = initialVC
    window?.makeKeyAndVisible()
    return true
}
Run Code Online (Sandbox Code Playgroud)

在情节提要中,导航栏也已启用: 在此处输入图片说明 最后,在viewController中,我做同样的事情:

override func viewWillAppear(_ animated: Bool) {
    self.navigationController?.setNavigationBarHidden(false, animated: animated)
    self.navigationController?.navigationBar.isHidden = false
    super.viewWillAppear(animated)
}
Run Code Online (Sandbox Code Playgroud)

但仍然在启动应用程序后,导航栏ist仍未显示: 在此处输入图片说明 有人可以告诉我为什么吗?

ios swift swift3

1
推荐指数
1
解决办法
2892
查看次数