aus irgendeinem Grund mein Code druckt die user.email
gut, aber es stellt nicht den Chatlog-Controller für den Benutzer, es tut einfach nichts?present collection view controller von einer UICollectionViewCell
(die func openUsersChatLogForUser()
aufgerufen wird, wenn ich auf eine Schaltfläche geklickt mit im Header)
mit in - class ProfilePageHeader: UICollectionViewCell
var messagesController: MessagesController?
func openUsersChatLogForUser(){
guard let user = self.profileUser else {return}
print(user.email!)
self.messagesController?.showChatControllerForUser(user)
}
die Funktion unten ist innerhalb der Klasse MessagesController: UITableViewController
func showChatControllerForUser(_ user: User2) {
let chatLogController = ChatLogController(collectionViewLayout: UICollectionViewFlowLayout())
chatLogController.user = user
navigationController?.pushViewController(chatLogController, animated: true)
}
dank Hexfire messageController ist gleich Null, wie würde ich es einstellen? – bennypalms661
Legen Sie den Wert einfach fest, wenn Sie die Sammlungsansicht mit Ihren benutzerdefinierten Zellen füllen. – Hexfire
Es ist 'collectionView (collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell' Methode, die Sie suchen. Beim Aufrufen von 'collectionView.dequeueReusableCellWithReuseIdentifier' wandeln Sie ihn in Ihre benutzerdefinierte Zelle um. rufen Sie dann: 'cell.messagesController' = ... Controller. – Hexfire