2017-07-21 10:34:14.447487+0530 demo[2783:104307] [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x60000009a6d0 UICollectionView:0x7fbc1b825800.width == 343 (active)>",
"<NSLayoutConstraint:0x61000009b670 H:|-(16)-[UICollectionView:0x7fbc1b825800] (active, names: '|':UIView:0x7fbc1a50d210 )>",
"<NSLayoutConstraint:0x61000009a680 H:[UICollectionView:0x7fbc1b825800]-(16)-| (active, names: '|':UIView:0x7fbc1a50d210 )>",
"<NSLayoutConstraint:0x60800009a6d0 'UIView-Encapsulated-Layout-Width' UIView:0x7fbc1a50d210.width == 320 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x60000009a6d0 UICollectionView:0x7fbc1b825800.width == 343 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView
listed in <UIKit/UIView.h> may also be helpful.
2017-07-21 10:34:14.453212+0530 demo[2783:104307] [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<_UILayoutSupportConstraint:0x61000009bd00 _UILayoutGuide:0x7fbc1a40ae80.height == 20 (active)>",
"<_UILayoutSupportConstraint:0x6100000986f0 V:|-(0)-[_UILayoutGuide:0x7fbc1a40ae80] (active, names: '|':UIView:0x7fbc1a50d210 )>",
"<_UILayoutSupportConstraint:0x61000009bda0 _UILayoutGuide:0x7fbc1a40b580.height == 0 (active)>",
"<_UILayoutSupportConstraint:0x61000009bd50 _UILayoutGuide:0x7fbc1a40b580.bottom == UIView:0x7fbc1a50d210.bottom (active)>",
"<NSLayoutConstraint:0x608000099a00 UIButton:0x7fbc1a40a5e0'Submit'.height == 30 (active)>",
"<NSLayoutConstraint:0x60000009a950 UICollectionView:0x7fbc1b825800.height == 589 (active)>",
"<NSLayoutConstraint:0x61000009b490 V:[UIButton:0x7fbc1a40a5e0'Submit']-(8)-[UICollectionView:0x7fbc1b825800] (active)>",
"<NSLayoutConstraint:0x61000009b710 V:[_UILayoutGuide:0x7fbc1a40ae80]-(0)-[UIButton:0x7fbc1a40a5e0'Submit'] (active)>",
"<NSLayoutConstraint:0x61000009b760 V:[UICollectionView:0x7fbc1b825800]-(20)-[_UILayoutGuide:0x7fbc1a40b580] (active)>",
"<NSLayoutConstraint:0x60800009af40 'UIView-Encapsulated-Layout-Height' UIView:0x7fbc1a50d210.height == 568 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x60000009a950 UICollectionView:0x7fbc1b825800.height == 589 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2017-07-21 10:34:14.457 demo[2783:104307] *** Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.7.47/UICollectionView.m:5115
2017-07-21 10:34:14.499 demo[2783:104307] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
*** First throw call stack:
(
0 CoreFoundation 0x000000010a16eb0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000107414141 objc_exception_throw + 48
2 CoreFoundation 0x000000010a172cf2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000106fae536 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 UIKit 0x000000010822cea3 -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:] + 1991
5 UIKit 0x000000010822d2fb -[UICollectionView dequeueReusableCellWithReuseIdentifier:forIndexPath:] + 169
6 demo 0x0000000106e2e7d6 _TFC4demo20SecondViewController14collectionViewfTCSo16UICollectionView13cellForItemAtV10Foundation9IndexPath_CSo20UICollectionViewCell + 150
7 demo 0x0000000106e2eaf7 _TToFC4demo20SecondViewController14collectionViewfTCSo16UICollectionView13cellForItemAtV10Foundation9IndexPath_CSo20UICollectionViewCell + 87
8 UIKit 0x0000000108218925 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 446
9 UIKit 0x0000000108218761 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 35
10 UIKit 0x000000010821d9bd -[UICollectionView _updateVisibleCellsNow:] + 4764
11 UIKit 0x000000010822338e -[UICollectionView layoutSubviews] + 313
12 UIKit 0x00000001079a955b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1268
13 QuartzCore 0x000000010cf38904 -[CALayer layoutSublayers] + 146
14 QuartzCore 0x000000010cf2c526 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 370
15 QuartzCore 0x000000010cf2c3a0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
16 QuartzCore 0x000000010cebbe92 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
17 QuartzCore 0x000000010cee8130 _ZN2CA11Transaction6commitEv + 468
18 QuartzCore 0x000000010cee8b37 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 115
19 CoreFoundation 0x000000010a114717 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
20 CoreFoundation 0x000000010a114687 __CFRunLoopDoObservers + 391
21 CoreFoundation 0x000000010a0f9038 CFRunLoopRunSpecific + 440
22 UIKit 0x00000001078e008f -[UIApplication _run] + 468
23 UIKit 0x00000001078e6134 UIApplicationMain + 159
24 demo 0x0000000106e319a7 main + 55
25 libdyld.dylib 0x000000010b10e65d start + 1
)
我正在使用swift编写应用程序,当我在iPhone模拟器上运行测试应用程序时,一切正常,但它崩溃并在控制台日志中显示此错误报告。另一件事是我刚刚创建了两个视图控制器应用程序和我已经设计了集合视图。在第一个视图控制器中它的工作但在第二个视图控制器中我的集合视图不起作用。
答案 0 :(得分:0)
&#39; NSInternalInconsistencyException&#39;,原因:&#39;无法使视图出列 种类:UICollectionElementKindCell与标识符单元格 - 必须 为标识符注册一个nib或类或连接原型 故事板中的单元格&#39;
该消息告诉我们,在您调用dequeueReusableViewOfKind
的地方发生崩溃,因为您没有首先将视图注册为部分页眉或页脚。您必须确保在设置集合视图时还要将页眉/页脚(使用xib
或类)注册到集合视图
标题:
与班级
collectionView.registerClass(YourHeaderClass.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "yourReuseIdentifier")
使用xib
var headerXib = UINib(nibName: "YourHeaderXib", bundle: nil)
collectionView.registerNib(headerXib, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: yourReuseIdentifier)
页脚:
与班级
collectionView.registerClass(SupplementaryViewClass.self, forSupplementaryViewOfKind: UICollectionElementKindSectionFooter, withReuseIdentifier: yourReuseIdentifier)
使用xib
var footerXib = UINib(nibName: "YourFooterXib", bundle: nil)
collectionView.registerNib(footerXib, forSupplementaryViewOfKind: UICollectionElementKindSectionFooter, withReuseIdentifier: yourReuseIdentifier)