Ios 在容器视图中嵌入NavigationController

Ios 在容器视图中嵌入NavigationController,ios,swift,xcode-storyboard,Ios,Swift,Xcode Storyboard,我正在尝试使用故事板在容器视图中嵌入导航控制器。我将容器视图添加到场景中,删除它自动生成的视图控制器,并控制从容器视图到导航控制器的拖动,创建一个分段 当我在模拟器中运行应用程序并过渡到包含容器视图的场景时,我得到以下异常: 2018-04-28 15:22:40.278627-0400 Woofr[8977:18656423]***由于未捕获的异常“NSUnknownKeyException”而终止应用程序,原因:“[setValue:forUndefinedKey:]:此类不符合key co

我正在尝试使用故事板在容器视图中嵌入导航控制器。我将容器视图添加到场景中,删除它自动生成的视图控制器,并控制从容器视图到导航控制器的拖动,创建一个分段

当我在模拟器中运行应用程序并过渡到包含容器视图的场景时,我得到以下异常:


2018-04-28 15:22:40.278627-0400 Woofr[8977:18656423]***由于未捕获的异常“NSUnknownKeyException”而终止应用程序,原因:“[setValue:forUndefinedKey:]:此类不符合key containerView的键值编码。”

如果我将它作为一个测试运行,并且只使用原始的自动生成的视图控制器,那么它可以工作。如果我在不删除自动生成的视图控制器的情况下控制从容器视图到导航控制器的拖动,序列图像板中的segue将被替换,但我在运行应用程序时会遇到相同的异常

ETA完整堆栈跟踪:

2018-04-28 15:44:22.748243-0400 Woofr[15437:18687945] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIStoryboardShowSegueTemplate 0x6040004756c0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key containerView.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001078521e6 __exceptionPreprocess + 294
    1   libobjc.A.dylib                     0x000000010699a031 objc_exception_throw + 48
    2   CoreFoundation                      0x00000001078520b9 -[NSException raise] + 9
    3   Foundation                          0x00000001063bbb47 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 292
    4   UIKit                               0x0000000108cc2d56 -[UIRuntimeOutletConnection connect] + 109
    5   CoreFoundation                      0x00000001077f4e8d -[NSArray makeObjectsPerformSelector:] + 317
    6   UIKit                               0x0000000108cc1700 -[UINib instantiateWithOwner:options:] + 1856
    7   UIKit                               0x00000001089dc137 -[UIViewController _loadViewFromNibNamed:bundle:] + 383
    8   UIKit                               0x00000001089dca64 -[UIViewController loadView] + 177
    9   UIKit                               0x00000001089dcd81 -[UIViewController loadViewIfRequired] + 175
    10  UIKit                               0x00000001089dd5d4 -[UIViewController view] + 27
    11  UIKit                               0x0000000108a0ec6e -[UINavigationController _startCustomTransition:] + 945
    12  UIKit                               0x0000000108a255e2 -[UINavigationController _startDeferredTransitionIfNeeded:] + 714
    13  UIKit                               0x0000000108a268cc -[UINavigationController __viewWillLayoutSubviews] + 150
    14  UIKit                               0x0000000108c7ebd7 -[UILayoutContainerView layoutSubviews] + 231
    15  UIKit                               0x0000000108908808 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1515
    16  QuartzCore                          0x00000001045d161a -[CALayer layoutSublayers] + 177
    17  QuartzCore                          0x00000001045d582b _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 395
    18  QuartzCore                          0x000000010455c29f _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 343
    19  QuartzCore                          0x0000000104589940 _ZN2CA11Transaction6commitEv + 568
    20  UIKit                               0x000000010883334f _UIApplicationFlushRunLoopCATransactionIfTooLate + 167
    21  UIKit                               0x0000000109198532 __handleEventQueueInternal + 6875
    22  CoreFoundation                      0x00000001077f4bb1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    23  CoreFoundation                      0x00000001077d94af __CFRunLoopDoSources0 + 271
    24  CoreFoundation                      0x00000001077d8a6f __CFRunLoopRun + 1263
    25  CoreFoundation                      0x00000001077d830b CFRunLoopRunSpecific + 635
    26  GraphicsServices                    0x000000010cb86a73 GSEventRunModal + 62
    27  UIKit                               0x00000001088390b7 UIApplicationMain + 159
    28  Woofr                               0x0000000100d34427 main + 55
    29  libdyld.dylib                       0x000000010b050955 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

2018-04-28 15:44:22.748243-0400 Woofr[15437:18687945]***由于未捕获的异常“NSUnknownKeyException”而终止应用程序,原因:“[setValue:forUndefinedKey:]:此类不符合key containerView的键值编码。”
***第一次抛出调用堆栈:
(
0 CoreFoundation 0x00000001078521e6例外预处理+294
1 libobjc.A.dylib 0x000000010699a031 objc_异常_抛出+48
2 CoreFoundation 0x00000001078520b9-[N异常提升]+9
3基金会0x000 000 01063BBB47 - [ NSObjices(NSKEY ValueCudid)设置值:FrKEY:] + 292
4 UIKit 0x0000000108cc2d56-[UIRuntimeOutletConnection connect]+109
5 CoreFoundation 0x00000001077f4e8d-[NSArray makeObjectsPerformSelector:+317
6 UIKit 0x0000000108cc1700-[UINib实例化所有者:选项:][1856
7 UIKit 0x00000001089dc137-[UIViewController\u loadViewFromNibNamed:bundle:][383
8 UIKit 0x00000001089dca64-[UIViewController loadView]+177
9 UIKit 0x00000001089dcd81-[UIViewController loadViewIfRequired]+175
10 UIKit 0x00000001089dd5d4-[UIViewController视图]+27
11 UIKit 0x0000000108a0ec6e-[UINavigationController\u startCustomTransition:+945
12 UIKit 0x0000000108a255e2-[UINavigationController\u STARTDEFERREEDTRANSION(如果需要):+714
13 UIKit 0x0000000108a268cc-[UINavigationController\uuu视图将布局子视图]+150
14 UIKit 0x0000000108c7ebd7-[UILayoutContainerView布局子视图]+231
15 UIKit 0x0000000108908808-[UIView(CALayerDelegate)布局层的子层:+1515
16夸脱核心0x00000001045d161a-[加莱尔布局子层]+177
17夸脱核心0x00000001045d582b锌层布局(如果需要)PNS交易+395
18 QuartzCore 0x000000010455c29f_ZN2CA7Context18提交交易PNS_11交易+343
19夸脱矿0x0000000104589940_Zn2Ca11交易承诺+568
20 UIKit 0x000000010883334f _UIApplicationFlushRunLopCatTransactionIftoolate+167
21 UIKit 0x0000000109198532 u u handleEventQueueInternal+6875
22 CoreFoundation 0x00000001077f4bb1\uuuu CFRUNLOOP\u正在调用\u OUT\u以执行\u函数\uuuu+17
23 CoreFoundation 0x00000001077d94af\uu CFRunLoopDoSources0+271
24 CoreFoundation 0x00000001077d8a6f__CFRunLoopRun+1263
25 CoreFoundation 0x00000001077d830b CFRunLoopRunSpecific+635
26图形服务0x000000010cb86a73 GSEventRunModal+62
27 UIKit 0x00000001088390b7 UIApplicationMain+159
28 Woofr 0x0000000100d34427干管+55
29 libdyld.dylib 0x000000010b050955开始+1
)
libc++abi.dylib:以NSException类型的未捕获异常终止
ETA设置场景屏幕截图:


在包含
containerView
的VC类中,确保为其添加IBOutlet

@IBOutlet var containerView:UIView!
//

当您将containerView拖到视图中并为其提供约束时,它将创建一个VC,其中包含来自该容器视图的序列,单击destinationVC并从编辑器->嵌入->导航控制器

//

在包含
containerView
的VC类中,确保为其添加IBOutlet

@IBOutlet var containerView:UIView!
//

当您将containerView拖到视图中并为其提供约束时,它将创建一个VC,其中包含来自该容器视图的序列,单击destinationVC并从编辑器->嵌入->导航控制器

//

I控件被拖动以添加该控件,但得到了相同的异常。是否符合关键containerView的值编码???还是另一种观点??发布新错误我不理解你的问题,但我编辑了问题以包含完整的堆栈跟踪。你能显示故事板的照片吗?有了扩展的视图,就这样,谢谢!不可能将导航控制器直接嵌入到容器视图中。您必须从Container视图向第一个视图控制器添加一个segue,然后将该VC嵌入导航控制器中。我拖动控件添加它,但得到了相同的异常。是否符合关键containerView的值编码???还是另一种观点??发布新错误我不理解你的问题,但我编辑了问题以包含完整的堆栈跟踪。你能显示吗