仅在 Gamecenter 中使用自动匹配

Only use Automatch in Gamecenter

如何从 GKMatchmakerViewController 中删除邀请朋友按钮?

打印其中的所有子视图时,我只看到导航栏。

我是这样介绍的:

GKMatchmakerViewController *mmvc = [[GKMatchmakerViewController alloc] initWithMatchRequest:request];

mmvc.matchmakerDelegate = self;

[viewController presentViewController:mmvc animated:YES completion:nil];

不幸的是,这是不可能的,我自己研究了删除快速匹配按钮,发现无法完成。

但是您可以设置自己的自定义邀请屏幕,请查看 iOS 文档的 'Real Time Matches' 部分中的 'Implementing a Custom Match User Interface' 部分。这里要显示的代码示例太多,我只需要提供说明和 link:

https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/GameKit_Guide/Matchmaking/Matchmaking.html

DESCRIPTION

Implementing a complete custom match interface can be as simple as displaying a network progress indicator until auto-matching completes, or as sophisticated as implementing a complete custom view controller that replicates the standard behavior. The latter is potentially a significant investment in programming time, as it needs to include support for all of the following:

  • Inviting specific players into a match
  • Listening for responses from invited players
  • Looking for nearby players (available via Wi-Fi or Bluetooth)

您可以使用 restrictToAutomatch 属性 移除“邀请好友”按钮。

let request = GKMatchRequest()
request.restrictToAutomatch = true

遗憾的是,没有 restrictToInviteFriends。