用UIstackview写布局出现terminating with uncaught exception of type NSException

LxxWLxx 2018-01-11 10:18:08
2018-01-10 19:49:07.856 Vcontrol[83189:1968385] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[2]'
*** First throw call stack:
(
0 CoreFoundation 0x013cfded __exceptionPreprocess + 189
1 libobjc.A.dylib 0x008a0d6f objc_exception_throw + 49
2 CoreFoundation 0x012e5407 -[__NSPlaceholderArray initWithObjects:count:] + 279
3 CoreFoundation 0x012ebda7 +[NSArray arrayWithObjects:count:] + 55
4 Vcontrol 0x000672fa -[ClientViewController platformStackView] + 229
5 Vcontrol 0x0006718b -[ClientViewController demoBackImage] + 217
6 Vcontrol 0x0006706f -[ClientViewController demoStackView] + 173
7 Vcontrol 0x00066e6a -[ClientViewController verticalStackView] + 308
8 Vcontrol 0x00066879 -[ClientViewController viewDidLoad] + 175
9 UIKit 0x0239a878 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 38
10 UIKit 0x0239f201 -[UIViewController loadViewIfRequired] + 1434
11 UIKit 0x023e3910 -[UINavigationController _layoutViewController:] + 52
12 UIKit 0x023e41b3 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 427
13 UIKit 0x023e4342 -[UINavigationController _startTransition:fromViewController:toViewController:] + 123
14 UIKit 0x023e54c9 -[UINavigationController _startDeferredTransitionIfNeeded:] + 979
15 UIKit 0x023e68f4 -[UINavigationController __viewWillLayoutSubviews] + 70
16 UIKit 0x025fe235 -[UILayoutContainerView layoutSubviews] + 235
17 UIKit 0x022a8d7f -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1418
18 libobjc.A.dylib 0x008b61d9 -[NSObject performSelector:withObject:] + 59
19 QuartzCore 0x01f6b0ea -[CALayer layoutSublayers] + 141
20 QuartzCore 0x01f5e486 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 398
21 QuartzCore 0x01f5e2e3 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 21
22 QuartzCore 0x01eeaa92 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 334
23 QuartzCore 0x01f17f8f _ZN2CA11Transaction6commitEv + 483
24 QuartzCore 0x01f18b30 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 124
25 CoreFoundation 0x01374536 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 22
26 CoreFoundation 0x013744a7 __CFRunLoopDoObservers + 391
27 CoreFoundation 0x01358fef CFRunLoopRunSpecific + 399
28 CoreFoundation 0x01358e4b CFRunLoopRunInMode + 123
29 UIKit 0x021cf0f6 -[UIApplication _run] + 488
30 UIKit 0x021d5bc9 UIApplicationMain + 148
31 Vcontrol 0x000648ef main + 96
32 libdyld.dylib 0x03a2a779 start + 1
33 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
用UIstackview必须把所有要加的控件都写出来吗?求大神解决!!!
...全文
991 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
LxxWLxx 2018-01-12
  • 打赏
  • 举报
回复
我解决了,可以运行,我是用代码写的,现在是stackview管理的控件没有显示,是我没有加约束所以没有宽高导致的嘛?
sjy457346652 2018-01-12
  • 打赏
  • 举报
回复
这不就原因咯:attempt to insert nil object from objects[2]。应该是往数组插入了空对象导致的错误。 这个数组也许是你的数据数组? 所以哥们,我觉得你该把你的情形描述下。是在向Stackview动态添加控件吗?

29,027

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧