Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为什么layer.presentationLayer()返回零?_Ios_Swift_Animation_Calayer - Fatal编程技术网

Ios 为什么layer.presentationLayer()返回零?

Ios 为什么layer.presentationLayer()返回零?,ios,swift,animation,calayer,Ios,Swift,Animation,Calayer,Xcode说明如下: 如果层尚未*提交,则返回nil 这在字面意义上是什么意思 我的代码如下: guard animalView?.layer.presentationLayer() != nil else { return QL4("Animal presentation layer was nil \(animalView?.layer)") } QL4打印日志,因此我们从用户处收到的一些日志如下。我似乎无法重现这种情况,而且只是偶尔发生。所以我的问题是presentationLa

Xcode说明如下:

如果层尚未*提交,则返回nil

这在字面意义上是什么意思

我的代码如下:

guard animalView?.layer.presentationLayer() != nil else {
    return QL4("Animal presentation layer was nil \(animalView?.layer)")
}
QL4打印日志,因此我们从用户处收到的一些日志如下。我似乎无法重现这种情况,而且只是偶尔发生。所以我的问题是presentationLayer()返回零的真正原因是什么?我最好的猜测是,该设备没有足够的可用电源来立即执行此任务,所以它确实会延迟一点时间

动物表示层为零可选(;动画={position=;position-2=;};层=>;子层=(,);allowsGroupOpacity=YES;;动画=[position=position-2=]>)

动物表示层为零可选(;动画={position=;position-2=;};层=>;子层=(,);allowsGroupOpacity=YES;;动画=[position=position-2=]>)

动物表示层为零可选(;动画={position=;position-2=;};层=>;子层=(,);allowsGroupOpacity=YES;;动画=[position=position-2=]>)

完整代码:

animalVC = AnimalVC()
VCOrganizer.mainVCInstance.addAsChildViewController(animalVC!, toView: VCOrganizer.mainVCInstance.view)
animalView = createAnimalView(animalItem!, x: 0, y: 0, sideSize: sideSize)

class AnimalVC: UIViewController {
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        let touch = touches.first
        touchLocation = touch!.locationInView(self.view)
        guard animalView != nil else {
            return QL4("Animal was nil \(animalView)")
        }
        guard animalView?.layer.presentationLayer() != nil else {
            return QL4("Animal presentation layer was nil \(animalView?.layer)")
        }
        if animalView!.layer.presentationLayer()!.hitTest(touchLocation) != nil {
            //                QL1("Clicked animal")
            clickedAnimal()
        } else {
            //                QL1("Clicked on background")
        }
    }
}
animalVC=animalVC()
VCOrganizer.mainVCInstance.addAsChildViewController(animalVC!,toView:VCOrganizer.mainVCInstance.view)
animalView=createAnimalView(animalItem!,x:0,y:0,sideSize:sideSize)
类AnimalVC:UIViewController{
覆盖功能触摸开始(触摸:设置,withEvent事件:UIEvent?){
让我们先接触
touchLocation=touch!.locationInView(self.view)
守卫动物视图!=没有其他{
返回QL4(“动物为零\(动物视图)”)
}
guard animalView?.layer.presentationLayer()!=无其他{
返回QL4(“动物表示层为零\(animalView?.layer)”)
}
如果animalView!.layer.presentationLayer()!.hitTest(touchLocation)!=nil{
//QL1(“点击的动物”)
clickedAnimal()
}否则{
//QL1(“点击背景”)
}
}
}

显示调用此代码的位置。我怀疑当视图还不可见(“呈现”)时。