我在swift编码,我从提交按钮收到以下错误消息。排行榜没有显示在模拟器中,只是给我下面的错误信息
var jsdom = require("jsdom");
var fs = require("fs");
fs.readFile('foo.html', 'utf8', function(error, data) {
jsdom.env(data, [], function (errors, window) {
var $ = require('jquery')(window);
$("p").each(function () {
var content = $(this).text();
$(this).text(content + " modified!");
});
fs.writeFile('out.html', window.document.documentElement.outerHTML,
function (error){
if (error) throw error;
});
});
});
以下是我应用中的所有游戏中心代码。
<GKGameCenterViewController: 0x7a8d0800> on <Chinese_Quiz.OpeningViewController: 0x78688aa0> whose view is not in the window hierarchy!
答案 0 :(得分:0)
解决这个问题:
func showLeaderboard() {
var vc = self.view?.window?.rootViewController
var gc = GKGameCenterViewController()
gc.gameCenterDelegate = self
vc?.presentViewController(gc, animated: true, completion: nil)
}
进入这个:
func showLeaderboard() {
var vc = self
var gc = GKGameCenterViewController()
var gameCenterDelegate: GKGameCenterControllerDelegate!
// Above text was replaced from gc.gameCenterDelegate = self
vc.presentViewController(gc, animated: true, completion: nil)
}
我不知道为什么,但它有效。