Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在iOS Swift中从xib UIViewController启动?_Ios_Swift_Uiviewcontroller_Xib_Carbonkit - Fatal编程技术网

如何在iOS Swift中从xib UIViewController启动?

如何在iOS Swift中从xib UIViewController启动?,ios,swift,uiviewcontroller,xib,carbonkit,Ios,Swift,Uiviewcontroller,Xib,Carbonkit,我一直在开发这个框架,我使用了carbonKit CoCoCoapods的选项卡菜单,现在我正在尝试导航UIVIewController xib 当UITabBarController加载carbonkit菜单时,将调用默认选项卡菜单 下面是用于加载xib UIViewcontroller的代码 public func carbonTabSwipeNavigation(_ carbonTabSwipeNavigation: CarbonTabSwipeNavigation, viewContr

我一直在开发这个框架,我使用了carbonKit CoCoCoapods的选项卡菜单,现在我正在尝试导航UIVIewController xib

当UITabBarController加载carbonkit菜单时,将调用默认选项卡菜单

下面是用于加载xib UIViewcontroller的代码

 public func carbonTabSwipeNavigation(_ carbonTabSwipeNavigation: CarbonTabSwipeNavigation, viewControllerAt index: UInt) -> UIViewController {
    print("called carbonkit")       
    print("carbon kit index 0 called")

    return (UINib(nibName: "FirstViewController", bundle: Bundle(for: FirstViewController.self)).instantiate(withOwner: nil, options: nil).first as? FirstViewController)!

}
以下是控制台输出:

 Called tab
   called carbonkit
  carbon kit index 0 called
 2019-11-12 22:13:02.350434+0530 A8FlowSampleApp[41059:1971714] *** 
 Terminating app due to uncaught exception 'NSUnknownKeyException', 
 reason: '[<NSObject 0x600000b1c8b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'
 *** First throw call stack:
(
0   CoreFoundation                      0x00007fff23c4f02e __exceptionPreprocess + 350
1   libobjc.A.dylib                     0x00007fff50b97b20 objc_exception_throw + 48
2   CoreFoundation                      0x00007fff23c4ebf9 -[NSException raise] + 9
3   Foundation                          0x00007fff256f2ef3 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 325
4   UIKitCore                           0x00007fff474b9a52 -[UIRuntimeOutletConnection connect] + 109
5   CoreFoundation                      0x00007fff23c3b052 -[NSArray makeObjectsPerformSelector:] + 242
6   UIKitCore                           0x00007fff474b6bfa -[UINib instantiateWithOwner:options:] + 2190
7   A8Flow                              0x0000000104db51d8 $s6A8Flow6MyTaskC24carbonTabSwipeNavigation_16viewControllerAtSo06UIViewJ0CSo06CarbonfgH0C_SutF + 1016
8   A8Flow                              0x0000000104db546d $s6A8Flow6MyTaskC24carbonTabSwipeNavigation_16viewControllerAtSo06UIViewJ0CSo06CarbonfgH0C_SutFTo + 77
9   CarbonKit                           0x00000001048c1d31 -[CarbonTabSwipeNavigation viewControllerAtIndex:] + 593
10  CarbonKit                           0x00000001048c18fb -[CarbonTabSwipeNavigation loadFirstViewController] + 411
11  CarbonKit                           0x00000001048bc90e -[CarbonTabSwipeNavigation initWithItems:delegate:] + 350
12  A8Flow                              0x0000000104db69f2 $sSo24CarbonTabSwipeNavigationC5items8delegateABSayypGSg_yptcfcTO + 242
13  A8Flow                              0x0000000104db4bc2 $sSo24CarbonTabSwipeNavigationC5items8delegateABSayypGSg_yptcfC + 50
14  A8Flow                              0x0000000104db40ba $s6A8Flow6MyTaskC11viewDidLoadyyF + 378
15  A8Flow                              0x0000000104db4dcb $s6A8Flow6MyTaskC11viewDidLoadyyFTo + 43
16  UIKitCore                           0x00007fff471cdb45 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 83
17  UIKitCore                           0x00007fff471d2a9e -[UIViewController loadViewIfRequired] + 1084
18  UIKitCore                           0x00007fff47136b8c -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 160
19  UIKitCore                           0x00007fff47136e8c -[UINavigationController _startTransition:fromViewController:toViewController:] + 140
20  UIKitCore                           0x00007fff47137d56 -[UINavigationController _startDeferredTransitionIfNeeded:] + 868
21  UIKitCore                           0x00007fff471390c1 -[UINavigationController __viewWillLayoutSubviews] + 150
22  UIKitCore                           0x00007fff47119ef7 -[UILayoutContainerView layoutSubviews] + 217
23  UIKitCore                           0x00007fff47d34cfd -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2478
24  QuartzCore                          0x00007fff2b138d41 -[CALayer layoutSublayers] + 255
25  QuartzCore                          0x00007fff2b13ef33 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 517
26  QuartzCore                          0x00007fff2b14a86a _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 80
27  QuartzCore                          0x00007fff2b0917c8 _ZN2CA7Context18commit_transactionEPNS_11TransactionEd + 324
28  QuartzCore                          0x00007fff2b0c6ad1 _ZN2CA11Transaction6commitEv + 643
29  UIKitCore                           0x00007fff47867481 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 81
30  CoreFoundation                      0x00007fff23bb204c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
31  CoreFoundation                      0x00007fff23bb17b8 __CFRunLoopDoBlocks + 312
32  CoreFoundation                      0x00007fff23bac644 
__CFRunLoopRun + 1284
33  CoreFoundation                      0x00007fff23babe16 
CFRunLoopRunSpecific + 438
34  GraphicsServices                    0x00007fff38438bb0 
GSEventRunModal + 65
35  UIKitCore                           0x00007fff4784fb68 
UIApplicationMain + 1621
36  A8FlowSampleApp                     0x000000010458a6bb main + 75
37  libdyld.dylib                       0x00007fff51a1dc25 start + 1
38  ???                                 0x0000000000000001 0x0 + 1
  )
  libc++abi.dylib: terminating with uncaught exception of type 
 NSException
 (lldb) 
调用选项卡
叫carbonkit
已调用碳套件索引0
2019-11-12 22:13:02.350434+0530 A8FlowSampleApp[41059:1971714]***
由于未捕获异常“NSUnknownKeyException”而终止应用程序,
原因:“[setValue:forUndefinedKey:]:此类不符合密钥视图的密钥值编码。”
***第一次抛出调用堆栈:
(
0 CoreFoundation 0x00007fff23c4f02e例外预处理+350
1 libobjc.A.dylib 0x00007fff50b97b20 objc_异常_抛出+48
2 CoreFoundation 0x00007fff23c4ebf9-[N异常升高]+9
3基金会0x000 7FFF256F2EF3- [ NSObjices(NSKEY ValueCudid)设置值:FrKEY:] + 325
4 UIKitCore 0x00007fff474b9a52-[UIRuntimeOutletConnection connect]+109
5 CoreFoundation 0x00007fff23c3b052-[NSArray makeObjectsPerformSelector:+242
6 UIKitCore 0x00007fff474b6bfa-[UINib实例化所有者:选项:][2190
7 A8流量0x0000000104db51d8$S6a8流量6mytaskc24碳表,带激活\u 16视图控制器SO06UIVIEWJ0CSO06CARBONFGH0C\u SutF+1016
8A8Flow 0x0000000104db546d$S6A8Flow 6Mytaskc24Carbontabswipenavigation\u 16视图控制器SO06UIVIEWJ0CSO06CarbonFGH0C\u SutFTo+77
9 CarbonKit 0x00000001048c1d31-[CarbonTabSwipenAviation视图控制器索引:+593
10 CarbonKit 0x00000001048c18fb-[CarbonTabSwipenAgation loadFirstViewController]+411
11 CarbonKit 0x00000001048bc90e-[CarbonTabswipenaviation initWithItems:delegate::+350
12 A8流量0x0000000104db69f2$SSO24碳表未激活C5项目8授权ABSAYPGSG_-yptCFTO+242
13 A8Flow 0x0000000104db4bc2$SSO24碳表已授权项目8授权ABSAYPGSG_-yptcfC+50
14 A8流量0x0000000104db40ba$S6A8流量6MYTASKC11VIEWDIDLOADDYYF+378
15 A8Flow 0x0000000104DB4DB$S6A8Flow6Mytaskc11ViewDidLoadyyyFTO+43
16 UIKitCore 0x00007fff471cdb45-[UIViewController\u SendViewDidLoadWith AppearanceProxyObjectTaggingEnabled]+83
17 UIKitCore 0x00007fff471d2a9e-[UIViewController loadViewIfRequired]+1084
18 UIKitCore 0x00007fff47136b8c-[UINavigationController\u更新从ViewController:到ViewController:+160的滚动视图
19 UIKitCore 0x00007fff47136e8c-[UINavigationController\u开始转换:从ViewController:到ViewController:+140
20 UIKitCore 0x00007fff47137d56-[UINavigationController\u StartDeferredTransition(如果需要):+868
21 UIKitCore 0x00007FFF47139C1-[UINavigationController\uuuu视图将布局子视图]+150
22 UIKitCore 0x00007fff47119ef7-[UILayoutContainerView布局子视图]+217
23 UIKitCore 0x00007fff47d34cfd-[UIView(CALayerDelegate)布局层的子层:+2478
24夸脱芯0x00007fff2b138d41-[CALayer layoutSublayers]+255
25夸脱芯0x00007fff2b13ef33(如果需要)层布局(交易+517)
26夸脱芯0x00007fff2b14a86a _Zn2CA5层28布局和显示(如果需要)PNS 11事务+80
27 QuartzCore 0x00007fff2b0917c8_ZN2CA7Context18commit_TransactionPNS_11 Transactiond+324
28夸脱芯0x00007fff2b0c6ad1_ZN2CA11交易承诺+643
29 UIKitCore 0x00007fff47867481 \uuu34-[UIApplication\uFirstCommitBlock]\uBlock\uInvoke\u2+81
30 CoreFoundation 0x00007fff23bb204c\uuuu CFRUNLOOP\u正在调用\u OUT\u到\u块\uuuu+12
31 CoreFoundation 0x00007fff23bb17b8\uuu CFRunLoopDoBlocks+312
32 CoreFoundation 0x00007fff23bac644
__CFRunLoopRun+1284
33 CoreFoundation 0x00007FFF2316
CFRunLoopRunSpecific+438
34图形服务0x00007fff38438bb0
GSEventRunModal+65
35 UIKitCore 0x00007fff4784fb68
UIApplicationMain+1621
36 A8FlowSampleApp 0x000000010458a6bb干管+75
37 libdyld.dylib 0x00007fff51a1dc25启动+1
38°?0x0000000000000001 0x0+1
)
libc++abi.dylib:以类型为的未捕获异常终止
N例外
(lldb)
非常感谢您的帮助。。尝试了很多方法来实现它,但都没有成功。

我自己解决了这个问题

func firstView() -> UIViewController {

    let cont = FirstViewController()
    self.tabContView?.addChild(cont)
    self.tabContView?.view.addSubview(cont.view)
    cont.didMove(toParent: tabContView)
    return cont
 }

public func carbonTabSwipeNavigation(_ carbonTabSwipeNavigation: CarbonTabSwipeNavigation, viewControllerAt index: UInt) -> UIViewController {
print("called carbonkit")       
print("carbon kit index 0 called")

return firstView()

}