游戏中心朋友列表 [英] Game Center Friend List

查看:117
本文介绍了游戏中心朋友列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部

我为Apple iOS制作了一款游戏。现在我想在Apple的游戏中心显示我的朋友列表。

I made a game for the Apple iOS. Now I would like to show my friend list in Apple's Game Center.

如何在iPhone上显示登录播放器的Game Center好友列表,可能使用UIViewController(管理ViewControllers)?

How can I show the Game Center friend list of a logged in player on an iPhone, possibly using the UIViewController (which manages the ViewControllers)?

任何帮助都将不胜感激..

Any help would be appreciated..

谢谢...

推荐答案

要在您的应用中显示您的游戏中心朋友,您可以使用以下代码。

To show your Game center friends in your app you can use the below code given.

     -(void) retrieveFriends
   {
          GKLocalPlayer *lp = [GKLocalPlayer localPlayer]; 
          if (lp.authenticated)   
         { 
             [lp loadFriendsWithCompletionHandler:^(NSArray *friends, NSError *error)
             {
                 if (friends != nil)
                 {
                      [self loadPlayerData: friends];
                 }

             }];

         }

    }



       -(void) loadPlayerData: (NSArray *) identifiers
        {
             [GKPlayer loadPlayersForIdentifiers:identifiers withCompletionHandler:^(NSArray *players, NSError *error) 
           {

              if (error != nil) 
                {
                  // Handle the error.
                } 
             if (players != nil) 
               {
          // Process the array of GKPlayer objects.
               } 
           }];

          }

如需更多参考,您可以使用Apple Game KIT指南。下面是它的链接

For more reference you can use the Apple Game KIT guide. below is the link to it

http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/GameKit_Guide/Introduction/Introduction.html

希望它有所帮助......

Hope it helps..

这篇关于游戏中心朋友列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆