我在标签中显示了两个tableView。对于打开的第一个,没有错误,但在选择第二个选项卡时,会出现错误:
2016-05-17 21:07:23.730 FeastApp[11007:172938] *** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.60.7/UITableView.m:6573
2016-05-17 21:07:23.736 FeastApp[11007:172938] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier GroupMessageCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
即使我已将行标识符设置为:GroupMessageCell
:
在我的嵌套TableView中:
和班级:
class GroupMessageList: UITableViewController {
var getGroups: Firebase!
var groups: [Group] = []
override func viewDidLoad() {
super.viewDidLoad()
getGroupsWithMessages()
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
}
// MARK: - Table View
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.groups.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("GroupMessageCell", forIndexPath: indexPath)
let group: Group
group = groups[indexPath.row]
// Update the rows with the proper object
cell.textLabel!.text = "\(group.groupName) \(group.groupID)"
return cell
}
func getGroupsWithMessages() {
getGroups = Firebase(url: Global.sharedInstance.firebaseMainURL + "usersGroups/" + Global.sharedInstance.userID)
self.getGroups.observeSingleEventOfType(.Value, withBlock: { snapshot in
print(snapshot)
for detailData in snapshot.children {
// print(detailData.value)
self.groups.append(Group(groupName: "test", groupID: detailData.key))
print(self.groups.count)
}
self.tableView!.reloadData()
})
}
}
如何防止发生此错误?