gpt4 book ai didi

ios - 添加容器导致 NSInternalInconsistencyException

转载 作者:行者123 更新时间:2023-11-28 07:33:50 28 4
gpt4 key购买 nike

我正在尝试向我的应用添加容器 View 。但是,它不断崩溃并出现以下错误:

'NSInternalInconsistencyException',原因:'containerView 是必需的。'

我做了一个新的项目来测试错误发生的时间。当我添加一个容器 View 并将其分配给“viewController”类时,它工作正常(链接的图片显示了这一点)。然后我添加一个名为“MainViewController”的新 UIPagecontroller 类并将其分配给容器所在的原始 viewController - 当我运行它时它崩溃并出现相同的错误 - 这是为什么?

我还没有添加任何代码,所以我没有任何链接,但这是控制台错误:

2018-12-18 21:25:38.171283+0000 caca2[19001:1863302] *** Assertion failure in -[UIStoryboardEmbedSegueTemplate newDefaultPerformHandlerForSegue:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3698.54.4/UIStoryboardEmbedSegueTemplate.m:34
2018-12-18 21:25:38.190027+0000 caca2[19001:1863302] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'containerView is required.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107b921e6 __exceptionPreprocess + 294
1 libobjc.A.dylib 0x0000000103ff8031 objc_exception_throw + 48
2 CoreFoundation 0x0000000107b97472 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000103a9b652 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 UIKit 0x00000001054cb49e __67-[UIStoryboardEmbedSegueTemplate newDefaultPerformHandlerForSegue:]_block_invoke + 796
5 UIKit 0x00000001051b8f47 -[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 276
6 UIKit 0x00000001051b8e05 -[UIStoryboardSegueTemplate _perform:] + 82
7 UIKit 0x00000001051b90c7 -[UIStoryboardSegueTemplate perform:] + 157
8 UIKit 0x0000000104a37f11 -[UIViewController loadViewIfRequired] + 671
9 UIKit 0x0000000104a38574 -[UIViewController view] + 27
10 UIKit 0x0000000104906123 -[UIWindow addRootViewControllerViewIfPossible] + 122
11 UIKit 0x0000000104906834 -[UIWindow _setHidden:forced:] + 294
12 UIKit 0x00000001049195cc -[UIWindow makeKeyAndVisible] + 42
13 UIKit 0x000000010488d3da -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4739
14 UIKit 0x00000001048925cb -[UIApplication _runWithMainScene:transitionContext:completion:] + 1677
15 UIKit 0x0000000104c54f7e __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 866
16 UIKit 0x0000000105027a39 +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 153
17 UIKit 0x0000000104c54bba -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 236
18 UIKit 0x0000000104c553db -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 675
19 UIKit 0x00000001055c6614 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 299
20 UIKit 0x00000001055c64ae -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 433
21 UIKit 0x00000001052aa75d __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 221
22 UIKit 0x00000001054a54b7 _performActionsWithDelayForTransitionContext + 100
23 UIKit 0x00000001052aa627 -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 223
24 UIKit 0x00000001050270e0 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 392
25 UIKit 0x0000000104890eac -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 515
26 UIKit 0x0000000104e63bcb -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 361
27 FrontBoardServices 0x0000000109bc22f3 -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 331
28 FrontBoardServices 0x0000000109bcacfa __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 225
29 libdispatch.dylib 0x0000000108cf67ec _dispatch_client_callout + 8
30 libdispatch.dylib 0x0000000108cfbdb8 _dispatch_block_invoke_direct + 592
31 FrontBoardServices 0x0000000109bf6470 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
32 FrontBoardServices 0x0000000109bf612e -[FBSSerialQueue _performNext] + 439
33 FrontBoardServices 0x0000000109bf668e -[FBSSerialQueue _performNextFromRunLoopSource] + 45
34 CoreFoundation 0x0000000107b34bb1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
35 CoreFoundation 0x0000000107b194af __CFRunLoopDoSources0 + 271
36 CoreFoundation 0x0000000107b18a6f __CFRunLoopRun + 1263
37 CoreFoundation 0x0000000107b1830b CFRunLoopRunSpecific + 635
38 GraphicsServices 0x000000010a48ba73 GSEventRunModal + 62
39 UIKit 0x0000000104894057 UIApplicationMain + 159
40 caca2 0x00000001036edd37 main + 55
41 libdyld.dylib 0x0000000108d73955 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

任何有关如何解决此问题的帮助或建议将不胜感激!谢谢

模拟器和 xcode 工作区的图像:

enter image description here

最佳答案

简而言之,这是因为您所做的事情毫无意义。

  • 您的 ViewController 是一个带有单个 subview Controller 的父 View Controller ,通过嵌入转场在此处设置;它在“容器 View ”的边界中显示 subview Controller 的 View 。

  • UIPageViewController 也是一个带有单个 subview Controller 的父 View Controller ,它将显示为它的页面;它在自己 View 的整个边界内显示 subview Controller 的 View 。

这些是完全不同类型的 View 父 View Controller ,管理它们的 subview 并以完全不同的方式显示它的 View 。您必须选择一个或另一个; View Controller 不能同时是两种类型的父级。但这正是您想要实现的目标。

因此,如果您想要自定义父 View Controller (第一个选项),您应该从 Storyboard中显示的排列开始然后停止。如果您想要一个页面 View Controller ,您需要删除显示的所有内容并开始一个页面 View Controller 。

但是,还要注意您可以使用页面 View Controller 作为原始 View Controller 的 subview Controller 。这是完全合法的,而且很常见!事实上,能够做到这一点很重要,否则页面 View Controller 将始终全屏显示,这可能不是您想要的。

为此,不要将 ViewController 更改为 UIPageViewController;将 Storyboard(子级)中的其他 View Controller 更改为 UIPageViewController。

enter image description here

是你想改变成 UIPageViewController 的 View Controller ,这样做是合法的。删除这个 View Controller ,将一个 UIPageViewController 拖到 Storyboard中,并将一个新的 Embed Segue 从容器 View 拖到 UIPageViewController。

enter image description here

关于ios - 添加容器导致 NSInternalInconsistencyException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53841439/

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