0
由于某种原因,我的代码打印出user.email
罚款,但它没有提供用户的聊天记录控制器,它什么都不做?目前从UICollectionViewCell集合视图控制器
与(当i上的按钮与该首部点击func openUsersChatLogForUser()
被调用)在 - class ProfilePageHeader: UICollectionViewCell
var messagesController: MessagesController?
func openUsersChatLogForUser(){
guard let user = self.profileUser else {return}
print(user.email!)
self.messagesController?.showChatControllerForUser(user)
}
下面的功能是类内MessagesController: UITableViewController
func showChatControllerForUser(_ user: User2) {
let chatLogController = ChatLogController(collectionViewLayout: UICollectionViewFlowLayout())
chatLogController.user = user
navigationController?.pushViewController(chatLogController, animated: true)
}
感谢Hexfire messageController是等于零如何将我设置呢? – bennypalms661
只需在您的自定义单元格填充集合视图时设置它的值。 – Hexfire
它是您正在寻找的'collectionView(collectionView:UICollectionView,cellForItemAtIndexPath indexPath:NSIndexPath) - > UICollectionViewCell'方法。当调用'collectionView.dequeueReusableCellWithReuseIdentifier'时,你将它转换到你的自定义单元格。然后调用:'cell.messagesController' = ...控制器。 – Hexfire