gpt4 book ai didi

ios - UINavigationController 始终全屏不调整大小

转载 作者:行者123 更新时间:2023-11-29 00:17:16 24 4
gpt4 key购买 nike

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

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

为了让事情更复杂一些,我无法直接访问 View Controller (代码在管理器文件中)。这是创建和启动弹出窗口的代码:

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];

}];

This is what I am currently seeing - a fullscreen navigation bar with a root view controller

任何有关我做错的事情的提示将不胜感激!

最佳答案

我找到原因了,我好笨!

navigationController.modalTransitionStyle = UIModalPresentationFormSheet;

应该是

navigationController.modalPresentationStyle = UIModalPresentationFormSheet;

关于ios - UINavigationController 始终全屏不调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45030046/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com