-1
신속하게 앱을 프로그래밍 중이며 iPhone 시뮬레이터에서 테스트 앱을 실행할 때 모든 것이 작동하지만 다른 탭으로 이동하려고하면 충돌이 발생합니다. 이 오류 보고서를 콘솔 로그에 표시합니다.libC++ abi.dylib : NSException 유형의 캐치되지 않는 예외로 종료 오류
스위프트 3/엑스 코드 8.1/아이폰 OS 10.1
2016-11-28 22:36:23.440 BiOda[70323:2714339] *** Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.5.2/UICollectionView.m:4922
2016-11-28 22:36:23.445 BiOda[70323:2714339] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier CollectionViewCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
*** First throw call stack:
(
0 CoreFoundation 0x000000010a98a34b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000109fce21e objc_exception_throw + 48
2 CoreFoundation 0x000000010a98e442 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000109b64e4d -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 UIKit 0x000000010be1538b -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:] + 1960
5 UIKit 0x000000010be15834 -[UICollectionView dequeueReusableCellWithReuseIdentifier:forIndexPath:] + 169
6 BiOda 0x000000010853016c _TFC5BiOda29UsersCollectionViewController14collectionViewfTCSo16UICollectionView13cellForItemAtV10Foundation9IndexPath_CSo20UICollectionViewCell + 188
7 BiOda 0x0000000108530897 _TToFC5BiOda29UsersCollectionViewController14collectionViewfTCSo16UICollectionView13cellForItemAtV10Foundation9IndexPath_CSo20UICollectionViewCell + 87
8 UIKit 0x000000010be00980 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 467
9 UIKit 0x000000010be007a7 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 35
10 UIKit 0x000000010be05c7f -[UICollectionView _updateVisibleCellsNow:] + 4803
11 UIKit 0x000000010be0b913 -[UICollectionView layoutSubviews] + 313
12 UIKit 0x000000010b582f50 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
13 QuartzCore 0x00000001102fccc4 -[CALayer layoutSublayers] + 146
14 QuartzCore 0x00000001102f0788 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
15 QuartzCore 0x00000001102f0606 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
16 QuartzCore 0x000000011027e680 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
17 QuartzCore 0x00000001102ab767 _ZN2CA11Transaction6commitEv + 475
18 QuartzCore 0x00000001102ac0d7 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 113
19 CoreFoundation 0x000000010a92ee17 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
20 CoreFoundation 0x000000010a92ed87 __CFRunLoopDoObservers + 391
21 CoreFoundation 0x000000010a913b9e __CFRunLoopRun + 1198
22 CoreFoundation 0x000000010a913494 CFRunLoopRunSpecific + 420
23 GraphicsServices 0x000000010e485a6f GSEventRunModal + 161
24 UIKit 0x000000010b4be964 UIApplicationMain + 159
25 BiOda 0x000000010852990f main + 111
26 libdyld.dylib 0x000000010d74768d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
UsersCollectionViewController
import UIKit
import FirebaseDatabase
private let reuseIdentifier = "CollectionViewCell"
class UsersCollectionViewController: UICollectionViewController {
@IBOutlet weak var aivLoading: UIActivityIndicatorView!
var databaseRef = FIRDatabase.database().reference()
var usersDict = NSDictionary()
var userNamesArray = [String]()
var userImagesArray = [String]()
override func viewDidLoad() {
super.viewDidLoad()
self.aivLoading.startAnimating()
self.databaseRef.child("user_profile").observe(.value, with: {
(snapshot) in
self.usersDict = snapshot.value as! NSDictionary
for(userId, details) in self.usersDict{
let img = (details as AnyObject).object(forKey: "profile_pic_small") as! String
let name = (details as AnyObject).object(forKey: "name") as! String
let firstName = name.components(separatedBy: " ")[0]
self.userImagesArray.append(img)
self.userNamesArray.append(firstName)
self.collectionView?.reloadData()
self.aivLoading.stopAnimating()
}
})
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func numberOfSections(in collectionView: UICollectionView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.userImagesArray.count
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as! CollectionViewCell
let imageUrl = NSURL(string:userImagesArray[indexPath.row])
let imageData = NSData(contentsOf: imageUrl! as URL)
cell.userImage.image = UIImage(data:imageData! as Data)
cell.userName.text = userNamesArray[indexPath.row]
return cell
}
}
감사합니다. 늦어서 미안해.. –