奇怪的问题在这里...我的项目的Swift文件,Main.Storyboard,附加图像,委托等文件都在Xcodes Project Navigator中丢失.
真正奇怪的是,项目构建正常,我也可以从主编辑器窗口的顶部选择它们,即使它们没有显示在Project Navigator的左侧.
当我打开我的项目时,文件显示大约1/2秒,然后列表被压缩到顶部的蓝色目标文件和大约7个图像.(我不能发布图片,因为我的声誉不够高.)
我已经退出并重新打开Xcode并执行了一些重启,但我仍然无法选择它们......即使它们显然在那里!有任何想法吗?
我正在使用UIPanGestureRecognizer将CALayer从一个UIView拖到另一个UIView.在UIGestureRecognizerState.Changed方法中,我正在调用移动CALayer
var touchLocation = recognizer.locationInView(recognizer.view)
self.panForTranslation(touchLocation)
Run Code Online (Sandbox Code Playgroud)
但是touchLocation返回CALayers相对于它的帧的位置,而不是屏幕坐标.
如何获得手指在屏幕上的确切点的UITouch位置?
我无法使用该SKTransaction对象crossFadeWithDuration.
它曾经为我完美地消除SKScene了当前的新内容SKScene,但现在它更像fadeWithDuration对象,在两个SKScenes之间留下了灰色的间隙.
我觉得最近的更新发生了这种差异,但直到现在我才注意到它.我只是用UIButton印刷机调用这个方法:
self.skView.presentScene(Puzzle1(size: (self.view?.bounds.size)!), transition: SKTransition.crossFadeWithDuration(2.0))
Run Code Online (Sandbox Code Playgroud)
有没有其他人有这个问题或知道任何解决方案/解决方法?
有几个问题像这样漂浮,但没有答案可行.
我正在为这样的UIView添加新的CALayers:
func placeNewPicture() {
let newPic = CALayer()
newPic.contents = self.pictureDragging.contents
newPic.frame = CGRect(x: pictureScreenFrame.origin.x - pictureScreenFrame.width/2, y: pictureScreenFrame.origin.y - pictureScreenFrame.height/2, width: pictureScreenFrame.width, height: pictureScreenFrame.height)
self.drawingView.layer.addSublayer(newPic)
}
Run Code Online (Sandbox Code Playgroud)
并试图删除它们:
func deleteDrawing() {
for layer in self.drawingView.layer.sublayers {
layer.removeFromSuperlayer()
}
}
Run Code Online (Sandbox Code Playgroud)
这会成功删除图像,但下次触摸屏幕时应用程序会崩溃,调用main但调试器中没有打印任何内容.有几种这样的情况,在删除子图层后,应用程序会在短时间内崩溃.
从父视图中删除CALayers的正确方法是什么?
我对这个真的很困惑。网络上有很多问题询问“如何从 Swift 中的 plist 文件获取信息?” 并且到处都发布了相同的答案:
let path = NSBundle.mainBundle().pathForResource("Config", ofType: "plist")
Run Code Online (Sandbox Code Playgroud)
然而,这条生产线总是nil为我生产。我已替换Config为默认 plist 文件中的其他组件,但nil也得到了。
ProductIdentifiers我正在尝试像这样访问我的自定义数组:
let url = NSBundle.mainBundle().URLForResource("ProductIdentifiers", withExtension: "plist")!
var productArray = NSArray(contentsOfURL: url) as! [[String:AnyObject!]]
Run Code Online (Sandbox Code Playgroud)
我在 ProductArray 上收到崩溃提示fatal error: unexpectedly found nil while unwrapping an Optional value。我还尝试过使用其他默认 plist 值来代替ProductIdentifiers.
有谁知道为什么这对我不起作用,尽管周围有很多人成功使用它的帖子?
我刚刚使用新的Swift 2安装了Xcode 7,现在我有50多个错误,说"stringByAppendingPathComponent"不可用,我应该使用"URLByAppendingPathComponent".我一直在设置所有的纹理属性,如下所示:
let dropTexture = SKTexture(image: UIImage(
contentsOfFile:NSBundle.mainBundle().resourcePath!.stringByAppendingPathComponent(
"P04_rainDrop1.png"))!)
Run Code Online (Sandbox Code Playgroud)
我一直这样做,所以当SKScene改变并且它一直运行良好时,他们不会留在记忆中.但是,直接替换"URLByAppendingPathComponent"并不能解决错误.
如何更改此设置以修复错误并获得相同的SKTexture?