いつもお世話になっております。
タイトルどおりなのですが、現在以下のようにコーディングし、六面体を表示して回転してアニメーション表示している状態です。面には文字を画像化したものを貼り付けています。
この状態から画面遷移を行うと遷移先で、表示しているボタン(UIButton)が押せなくなってしまいます。どういったことが考えられますでしょうか。
遷移先の画面は、以下のようにSCNSnapWindowというのが残っているのですがこれが直接の原因になっているのでしょうか。とくに画面自体には表示されてはいない状態です。
ご教示いただけますと幸いです。
よろしくお願いいたします。
Swift
1// 六面体を表示して回転 2let view = SCNView(frame: CGRect(x: scWid*0.2, y: scHei*0.1, width: scWid*0.6, height: scWid*0.6)) 3 self.view.addSubview(view) 4 view.tag = 50 5 // Sceneを生成して、Viewに追加 6 let scene = SCNScene() 7 view.scene = scene 8 view.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0) 9 10 // カメラ 11 //let camera = SCNCamera() 12 //let cameraNode = SCNNode() 13 camera = SCNCamera() 14 cameraNode = SCNNode() 15 16 cameraNode.camera = camera 17 cameraNode.position = SCNVector3(x: 0, y: 0, z: 3) 18 scene.rootNode.addChildNode(cameraNode) 19 // ライティング 20 view.autoenablesDefaultLighting = true 21 // ライトを設定しシーンに追加 22 //let lightNode = SCNNode() 23 lightNode = SCNNode() 24 lightNode.light = SCNLight() 25 lightNode.light!.type = SCNLight.LightType.omni 26 lightNode.position = SCNVector3(x: 0, y: 10, z: 10) 27 scene.rootNode.addChildNode(lightNode) 28 // アンビエントライトを設定しシーンに追加 29 //let ambientLightNode = SCNNode() 30 ambientLightNode = SCNNode() 31 ambientLightNode.light = SCNLight() 32 ambientLightNode.light!.type = SCNLight.LightType.ambient 33 ambientLightNode.light!.color = UIColor.darkGray 34 scene.rootNode.addChildNode(ambientLightNode) 35 let MPI:Float = Float(M_PI) 36 // 立方体のジオメトリを生成 37 let length:CGFloat = 0.7 //一辺の長さ 38 //let box = SCNBox(width: length, height: length, length: length, chamferRadius: 0.1) 39 box = SCNBox(width: length, height: length, length: length, chamferRadius: 0.1) 40 //let pyramid = SCNPyramid(width: length, height: length, length: length) 41 // マテリアルを変更 42 box.firstMaterial!.diffuse.contents = UIColor.blue 43 box.firstMaterial!.specular.contents = UIColor.white 44 // ノードに追加 45 //let boxNode = SCNNode(geometry: box) 46 boxNode = SCNNode(geometry: box) 47 var materials = [SCNMaterial]() 48 for i in 1...6 { 49 let material = SCNMaterial() 50 if i == 1 { material.diffuse.contents = imageViewArray[0] } 51 if i == 2 { material.diffuse.contents = imageViewArray[1] } 52 if i == 3 { material.diffuse.contents = imageViewArray[2] } 53 if i == 4 { material.diffuse.contents = imageViewArray[3] } 54 if i == 5 { material.diffuse.contents = imageViewArray[4] } 55 if i == 6 && imageViewArray.count == 6 { material.diffuse.contents = imageViewArray[5] } 56 if i == 6 && imageViewArray.count == 5 { material.diffuse.contents = UIColor.white } 57 materials.append(material) 58 } 59 boxNode.geometry?.materials = materials 60 scene.rootNode.addChildNode(boxNode) 61 // 立体が見えるように少し回転 62 boxNode.rotation = SCNVector4(x: 1.0, y: 1.0, z: 0.0, w: (MPI * 0.25)) 63 //アニメーション 0.5 1 0.2 mpi8 64 let spin = CABasicAnimation(keyPath: "rotation") 65 spin.toValue = NSValue(scnVector4:SCNVector4(x: 0.8 , y: 1 , z: 0.6 , w: MPI * 12.0)) 66 spin.duration = 21 67 spin.repeatCount = HUGE 68 boxNode.addAnimation(spin, forKey: "spin") 69 // ノードをシーンに追加 70 scene.rootNode.addChildNode(boxNode) 71 // SCNViewを探して取得 72 let scnView = self.view as! SCNView 73 // シーンをviewに追加 74 scnView.scene = scene 75 76
Swift
1 2// 画面遷移 3// 遷移するViewを定義する. 4 let mySecondViewController: UIViewController = ScoreViewController() 5 let appDelegate:AppDelegate = UIApplication.shared.delegate as! AppDelegate //AppDelegateのインスタンスを取得 6 appDelegate.correctRec = correctCount //appDelegateの変数を操作 7 appDelegate.totalscoreRec = totalscore 8 // アニメーションを設定する. 9 mySecondViewController.modalTransitionStyle = UIModalTransitionStyle.coverVertical 10 11 // Viewの移動する. 12 self.present(mySecondViewController, animated: true, completion: nil) 13