我有GKTurnBasedMatchmakerViewController一個關聯的GKTurnBasedMatchmakerViewControllerDelegate. 根據這個檔案頁面turnBasedMatchmakerViewControllerWasCancelled,當媒人被解散(不邀請任何玩家)時呼叫該函式。但是我在測驗時嘗試關閉媒人,甚至從未輸入過此功能。我誤解了什么turnBasedMatchmakerViewControllerWasCancelled嗎?
struct MatchmakerView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> GKTurnBasedMatchmakerViewController {
let request = // ...
let matchmakerViewController = GKTurnBasedMatchmakerViewController(matchRequest: request)
let matchmakerDelegate = MatchmakerDelegate()
matchmakerViewController.turnBasedMatchmakerDelegate = matchmakerDelegate
return matchmakerViewController
}
func updateUIViewController(_ uiViewController: GKTurnBasedMatchmakerViewController, context: Context) {}
}
private class MatchmakerDelegate: NSObject, GKTurnBasedMatchmakerViewControllerDelegate {
func turnBasedMatchmakerViewControllerWasCancelled(_ viewController: GKTurnBasedMatchmakerViewController) {
// FIXME: Dismissing the matchmaker does not call this method.
viewController.dismiss(animated: true)
print("This print statement is never reached")
}
}
uj5u.com熱心網友回復:
已解決:MatchmakerView缺少一個makeCoordinator方法。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/516019.html
