如何在UINavigationController前面展示相机?

时间:2018-02-27 01:11:18

标签: ios objective-c

iOS 10.3.1

在我的UINavigationController出现一个推送视图控制器后,我有以下视图层次结构(摘自顶部...不是完整深度)

(lldb) po [[[[UIApplication sharedApplication] windows] firstObject] recursiveDescription]
<UIWindow: 0x15592120; frame = (0 0; 768 1024); gestureRecognizers = <NSArray: 0x15592b80>; layer = <UIWindowLayer: 0x155923b0>>
   | <UITransitionView: 0x1840d0e0; frame = (0 0; 768 1024); autoresize = W+H; layer = <CALayer: 0x1732a4d0>>
   |    | <UILayoutContainerView: 0x1749a730; frame = (0 0; 768 1024); autoresize = W+H; gestureRecognizers = <NSArray: 0x16ec4900>; layer = <CALayer: 0x18509620>>
   |    |    | <UINavigationTransitionView: 0x17498d40; frame = (0 0; 768 1024); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x16e731b0>>
   |    |    |    | <UIViewControllerWrapperView: 0x185a5820; frame = (0 0; 768 1024); autoresize = RM+BM; layer = <CALayer: 0x16ae0f40>>
   |    |    |    |    | <UIView: 0x173f83c0; frame = (0 64; 768 960); autoresize = RM+BM; tag = 500; layer = <CALayer: 0x171775c0>>
   |    |    |    |    |    | <UIView: 0x16fda3b0; frame = (0 0; 768 35); autoresize = RM+BM; tag = 502; layer = <CALayer: 0x1681afa0>>

如何通过AppDelegate中的代码

在此前面展示相机

3 个答案:

答案 0 :(得分:0)

您可以向窗口添加视图

let window = UIApplication.shared.keyWindow!
window.addSubview((popupReference.view)!)

所以会出现在一切

之前

答案 1 :(得分:0)

@stevenpcurtis在评论中提到了解决方案。 我没有展示UINavigationController,而是将其添加到像这样的父容器视图中......

-(void)addAChildViewController:(UIViewController *)childViewController
    {
        [self addChildViewController:childViewController];
        [self.view addSubview:childViewController.view];
        [childViewController didMoveToParentViewController:self];
    }

而不是解雇UINavigationController,我只是用这样的代码删除它......

-(void)removeThisViewControllerFromItsParent
    {
        [self willMoveToParentViewController:nil];
        [self.view removeFromSuperview];
        [self removeFromParentViewController];
    }

答案 2 :(得分:0)

您可以向窗口添加视图

let window = UIApplication.shared.keyWindow!
window.addSubview((yourView)!)

其中yourView可以是一个容器(容器只是UIViews),然后可以使用上面的代码添加到窗口中