【问题标题】:UINavigationController always full screen not resizingUINavigationController 总是全屏不调整大小
【发布时间】:2017-07-11 09:06:12
【问题描述】:

我正在尝试在扫描二维码时显示模式弹出窗口。

我有一个 .xib 文件,其中包含必要的视图并链接到我的自定义视图控制器。通常的东西,除了我有一个导航控制器,以便稍后我可以在顶部添加一个关闭按钮和/或以防我需要推动另一个屏幕。

为了让事情更复杂一点,我没有直接访问视图控制器的权限(代码在管理器文件中)。这是创建和启动弹出窗口的代码:

self.m_scannerVC = [[BarcodeScannerVC alloc] initWithNibName:NSStringFromClass([BarcodeScannerVC class]) bundle:nil];

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.m_scannerVC];

// Set the navigation controller to be a modal popup.
navigationController.modalTransitionStyle = UIModalPresentationFormSheet;

// Set the size of the popup here.
navigationController.preferredContentSize = CGSizeMake(100, 200);

UIWindow *win = [[UIApplication sharedApplication].delegate window];
UINavigationController * winNav = (UINavigationController *)win.rootViewController;
winNav.providesPresentationContextTransitionStyle = YES;
winNav.definesPresentationContext = YES;
winNav.topViewController.providesPresentationContextTransitionStyle = YES;
winNav.topViewController.definesPresentationContext = YES;

winNav.modalPresentationStyle = UIModalPresentationOverCurrentContext;
winNav.topViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;

// And now present the view in a modal fashion.
[winNav.topViewController presentViewController:navigationController animated:YES completion:^{
    // Once presented, set the capture layer to fix inside our camera preview box.
    [self.captureLayer setFrame:self.m_scannerVC.m_viewCameraPreview.layer.bounds];
    // Adding the camera AVCaptureVideoPreviewLayer to our view's layer.
    [self.m_scannerVC.m_viewCameraPreview.layer addSublayer:self.captureLayer];

    // Start the camera capture session as soon as the view appears completely.
    [self.captureSession startRunning];

}];  

任何关于我做错的提示将不胜感激!

【问题讨论】:

    标签: ios objective-c uiviewcontroller uinavigationcontroller ios9


    【解决方案1】:

    我知道为什么了,我太笨了!

    navigationController.modalTransitionStyle = UIModalPresentationFormSheet;

    应该是

    navigationController.modalPresentationStyle = UIModalPresentationFormSheet;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-10
      • 2015-02-10
      • 1970-01-01
      • 1970-01-01
      • 2013-05-12
      • 2016-01-10
      相关资源
      最近更新 更多