內呼叫功能我想從我的TabBarController的不同選項卡內調用函數斯威夫特:從不同的標籤
func setupChatLogForUser(user: ChatPartner){
let layout = UICollectionViewFlowLayout()
let chatLog = ChatHistory(collectionViewLayout: layout)
chatLog.user = user
navigationController?.pushViewController(chatLog, animated: true)
}
。
I'm改變標籤的第一步,但鴕鳥政策知道如何使用navigationController推視圖控制器以及事後打電話與特定用戶的功能I'm ...
謝謝你的幫助!
編輯:
var chatsViewController:HomeScreen?
func chat(){
print("Chat clicked")
guard let chatFriends = self.friend else {return}
print(chatFriends)
self.tabBarController?.selectedIndex = 0
self.chatsViewController?.setupChatLogForUser(user: chatFriends)
}
從其他類中獲取該TabBar類的實例並調用該方法。 – TheValyreanGroup
試過了,沒有工作。當在同一個選項卡中調用該函數時,此工作正常。但是,從不同的標籤內呼叫時,它似乎無法正常工作。 – ktm125
請顯示您試圖稱呼它的內容。 – TheValyreanGroup