This is the current situation.
The part I want to implement is to select a cell in the tableView Controller and put the data (using core data x) that fits the cell into the variable in the collectionView and reset the view with the contents.
It's a question.
There is no problem with the initial startup, but the function works well when you select a cell in the tableViewController.After self.collectionView.reloadData()
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate { //Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
There is an error in the . I don't know why it flies. It's been blocked for a week
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'UICollectionView must be initialized with a non-nil layout parameter'
*** *** First throw call stack:
(
0 CoreFoundation 0x000000010c219d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010dfbddeb objc_exception_throw + 48
2 CoreFoundation 0x000000010c219cbd +[NSException raise:format:] + 205
3 UIKit 0x000000010d2b3612 -[UICollectionView initWithFrame:collectionViewLayout:] + 76
4 UIKit 0x000000010d2f1622 -[UICollectionViewController _newCollectionViewWithFrame:collectionViewLayout:] + 108
5 UIKit 0x000000010d2f07b1 -[UICollectionViewController loadView] + 675
6 UIKit 0x000000010cbdc560 -[UIViewController loadViewIfRequired] + 138
7 UIKit 0x000000010d2f12e4 -[UICollectionViewController collectionView] + 22
8 Home Control Client 0x000000010c010418 _TFC19Home_Control_Client28ControllerListCollectionView21GetZoneControllerListfVCS_13ZoneListBrain4zoneT_ + 1400
9 Home Control Client 0x000000010c01731c _TFC19Home_Control_Client13ZoneListBrain23DeliveryAtTheZoneNumberfSiT_ + 620
10 Home Control Client 0x000000010c014b78 _TFC19Home_Control_Client17ZoneListTableView9tableViewfTCSo11UITableView23didSelectRowAtIndexPathCSo11NSIndexPath_T_ + 504
11 Home Control Client 0x000000010c014bff _TToFC19Home_Control_Client17ZoneListTableView9tableViewfTCSo11UITableView23didSelectRowAtIndexPathCSo11NSIndexPath_T_ + 79
12 UIKit 0x000000010cb891c6 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1887
13 UIKit 0x000000010cb8941b -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 388
14 UIKit 0x000000010ca4df62 _runAfterCACommitDeferredBlocks + 317
15 UIKit 0x000000010ca61e4c _cleanUpAfterCAFlushAndRunDeferredBlocks + 95
16 UIKit 0x000000010ca6e147 _afterCACommitHandler + 90
17 CoreFoundation 0x000000010c13ec37 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
18 CoreFoundation 0x000000010c13eba7 __CFRunLoopDoObservers + 391
19 CoreFoundation 0x000000010c1347fb __CFRunLoopRun + 1147
20 CoreFoundation 0x000000010c1340f8 CFRunLoopRunSpecific + 488
21 GraphicsServices 0x00000001108afad2 GSEventRunModal + 161
22 UIKit 0x000000010ca41f09 UIApplicationMain + 171
23 Home Control Client 0x000000010c01a562 main + 114
24 libdyld.dylib 0x000000010ea8192d start + 1
25 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Try adding UICollectionViewFlowLayout to viewDidLoad().
let aFlowLayout = UICollectionViewFlowLayout()
aFlowLayout.itemSize = CGSizeMake(100, 22)
self.collectionView.collectionViewLayout = aFlowLayout
It is essential to put it in the collection view when not using autoLayout, but I am not sure if this is right because it occurs when the layout setting is not initialized. Please try putting it in and check if it works. I'm sorry it's not an exact answer
Did you solve it?I keep getting stuck with the same problem
© 2024 OneMinuteCode. All rights reserved.