【问题标题】:iOS 6 GKMatchRequest playersToInvite fails with nil playerID in GKTurnBasedParticipant (works iOS5)iOS 6 GKMatchRequest playerToInvite 在 GKTurnBasedParticipant 中以 nil playerID 失败(适用于 iOS5)
【发布时间】:2012-09-24 15:09:14
【问题描述】:

几周前,我创建了一个在 iOS 5 上运行的基于回合制的 2 人游戏。

游戏允许玩家在自己的界面中从好友中选择一个对手,然后在呈现匹配视图时使用GKMatchRequest的playersToInvite属性,以使其自动邀请他们。

与在 iOS6 之前说它“什么都不做”的文档相反,这会导致 GKTurnBasedMatchmakerViewController 在 iOS5 上运行时自动选择所选玩家并开始邀请。

请求返回时,在:

- (void)turnBasedMatchmakerViewController:(GKTurnBasedMatchmakerViewController *)viewController didFindMatch:(GKTurnBasedMatch *)match 

然后,此应用程序会立即执行转弯并将其传递给下一位玩家。 这会导致其他玩家在轮到他们的同时发生实际邀请,并且游戏从那里顺利进行。

上述委托调用中的 match.participants 都包含有效的 playerID 属性,使得“nextParticipant”调用成为可能且有效。

到目前为止,在 iOS 5 上一切都很好。

但是,在 iOS 6 上运行时,一切照常进行,直到我们到达

- (void)turnBasedMatchmakerViewController:(GKTurnBasedMatchmakerViewController *)viewController didFindMatch:(GKTurnBasedMatch *)match 

我们发现第二个参与者的 playerID 为零,尝试将其设置为下一个参与者失败,并显示“未知操作”。

进一步调查,如果我像往常一样开始匹配请求,但随后在 GC UI 中取消邀请,然后通过 GC UI 再次邀请,这一切都按预期工作。只有在自己设置 playerToInvite 时,邀请才会失败。我已经确认 playerID 在所有情况下都是正确的,除了 iOS6 上的虚假 nil。

请注意,在 iOS5 上运行时,这一切都正常运行。

在我看来,Apple 让它在 iOS5 中工作并声称它没有,然后在 iOS6 中破坏它并声称它可以工作:)

【问题讨论】:

    标签: ios6 game-center multiplayer


    【解决方案1】:

    以防万一这对某人有用:

    我通过为 iOS6 添加特定的实现来解决这个问题。 因此,在邀请玩家时,不要像在 iOS5 中那样启动 MatchMakerVC,而是以编程方式进行。

    [GKTurnBasedMatch findMatchForRequest: request withCompletionHandler:^(GKTurnBasedMatch *match, NSError *error)
    

    这实际上比它在 iOS5 中的效果更好,因为您可以避免强迫用户点击“下一步”3 次。

    我仍然认为最初的问题是一个错误,在这里浪费了我 50 名声望,但我们在那里生活和学习,忘记并再次学习 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-06
      • 1970-01-01
      • 1970-01-01
      • 2014-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多