我的应用程序正在运行 Spritekit,并且专为横向设计,我终究无法弄清楚为什么当我在 Game Center 中显示用于验证玩家的模态视图时,键盘不见了。
这是我目前的代码。
class GameViewController: UIViewController, ADBannerViewDelegate, GKGameCenterControllerDelegate {
var gameCenterEnabled: Bool = false
var initialized: Bool = false
let leaderBoardIdentifier: String = "squareBeatLeaderboard"
@IBOutlet var bannerView: ADBannerView!
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
// Configure the view.
if initialized == false {
let skView = self.originalContentView as SKView
let scene = GameScene.sceneWithSize(CGSize(width: self.originalContentView.frame.size.width, height: self.originalContentView.frame.size.height))
skView.ignoresSiblingOrder = true
scene.scaleMode = SKSceneScaleMode.ResizeFill
self.authenticateLocalPlayer()
skView.presentScene(scene)
initialized = true
}
}
func authenticateLocalPlayer() {
let localPlayer = GKLocalPlayer()
localPlayer.authenticateHandler = {(viewController: UIViewController!, error: NSError!) -> Void in
// handle authentication
if let viewController = viewController {
self.presentViewController(viewController, animated: true, completion: nil)
//keyboard
NSLog("log the user in") // why the hell is there no keyboard
} else {
if GKLocalPlayer().authenticated == true {
self.gameCenterEnabled = true
} else {
self.gameCenterEnabled = false
}
}
}
}
“已初始化” bool 值用于确保在我的 iAd 刷新时不会再次加载设置。
当 Game Center 登录 View 出现时,它看起来一切正常,只是键盘位置不正确。在 iPhone 4S 模拟器中,是这样的: http://i.imgur.com/TJjfYq2.png
最佳答案
这看起来像是旋转错误。就像键盘显示的是纵向坐标,但 View 是横向的。如果您的应用程序在 info.plist 文件中设置为仅横向显示,那么您必须以某种方式覆盖它。如果它没有设置在那里,那么我会锁定它,除非你需要纵向。
当你有混合方向但不知何故 View 呈现不正确时的修复,通过设置方向掩码强制 View 的横向模式:
教程在这里:
http://makeapppie.com/tag/uiinterfaceorientationmask/
其他代码示例可以在下面的 Ray Wenderlich 教程中找到。下载启动项目:
http://www.raywenderlich.com/82022/create-game-like-cut-the-rope-using-sprite-kit-swift
关于ios - 在 Spritekit 中横向显示 Game Center Modal View Controller 时没有键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24585116/
我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我好像记得Lua有类似Ruby的method_missing的东西。还是我记错了? 最佳答案 表的metatable的__index和__newindex可以用于与Ruby的method_missing相同的效果。 关于ruby-难道Lua没有和Ruby的method_missing相媲美的东西吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/7732154/
我有一个奇怪的问题:我在rvm上安装了rubyonrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(
我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re
所以我在关注Railscast,我注意到在html.erb文件中,ruby代码有一个微弱的背景高亮效果,以区别于其他代码HTML文档。我知道Ryan使用TextMate。我正在使用SublimeText3。我怎样才能达到同样的效果?谢谢! 最佳答案 为SublimeText安装ERB包。假设您安装了SublimeText包管理器*,只需点击cmd+shift+P即可获得命令菜单,然后键入installpackage并选择PackageControl:InstallPackage获取包管理器菜单。在该菜单中,键入ERB并在看到包时选择
我试图在索引页中创建一个超链接,但它没有显示,也没有给出任何错误。这是我的index.html.erb代码。ListingarticlesTitleTextssss我检查了我的路线,我认为它们也没有问题。PrefixVerbURIPatternController#Actionwelcome_indexGET/welcome/index(.:format)welcome#indexarticlesGET/articles(.:format)articles#indexPOST/articles(.:format)articles#createnew_articleGET/article
我正在尝试在Ruby中制作一个cli应用程序,它接受一个给定的数组,然后将其显示为一个列表,我可以使用箭头键浏览它。我觉得我已经在Ruby中看到一个库已经这样做了,但我记不起它的名字了。我正在尝试对soundcloud2000中的代码进行逆向工程做类似的事情,但他的代码与SoundcloudAPI的使用紧密耦合。我知道cursesgem,我正在考虑更抽象的东西。广告有没有人见过可以做到这一点的库或一些概念证明的Ruby代码可以做到这一点? 最佳答案 我不知道这是否是您正在寻找的,但也许您可以使用我的想法。由于我没有关于您要完成的工作
我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c
这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下