2014-11-08 86 views
0

我正在嘗試將遊戲中心集成到我的應用程序中。我花了很多時間來解決這個問題,需要一些幫助。這是我到目前爲止:遊戲中心登錄Swift

func login() { 
    println("login called") 
    var localPlayer = GKLocalPlayer() 
    localPlayer.authenticateHandler = {(viewController: UIViewController!, error: NSError!) -> Void in 
     if viewController != nil { 
      println("VC True") 
      self.presentViewController(viewController, animated: true, completion: nil) 

     }else if GKLocalPlayer.localPlayer().authenticated{ 

      //WHAT HERE? 
     } 
    } 
} 

我做了一個登錄函數,我在視圖中調用加載。

感謝您的幫助。

+0

沒關係這個作品! – 2014-11-08 04:37:33

+0

你有沒有得到https://github.com/DaRkD0G/Easy-Game-Center-Swift? – YannickSteph 2015-04-11 13:03:45

+0

@YannickSteph上面的github鏈接不可用 – Rajesh 2018-01-17 12:18:15

回答

0

您可以使用,我在github上創建的iOS遊戲中心的簡單類 https://github.com/DaRkD0G/Easy-Game-Center-Swift

開始

import GameKit 
/// The local player object. 
let gameCenterPlayer = GKLocalPlayer.localPlayer() 

後您的FUNC

self.gameCenterPlayer.authenticateHandler={(var gameCenterVC:UIViewController!, var gameCenterError:NSError!) -> Void in 

     if gameCenterVC != nil { 
      self.presentViewController(gameCenterVC, animated: true, completion: {() -> Void in 
       // no idea 
      }) 
     } 
    } 
+0

您的Easy Game Center庫在'EGC.printLogEGC(「新委託UIViewController是\(_ stdlib_getDemangledTypeName(newValue))\ n」)'返回錯誤。換句話說,我無法訪問我的視圖控制器中的EGC。謝謝 – Cesare 2016-04-07 15:35:18