我们在iOS9上部署时使用SceneKit的应用程序遇到了问题。该应用程序在iOS8.0-8.4上运行良好,但在iOS9上部署时,它会立即崩溃。查看崩溃日志,我们在一个线程中看到了一个EXC_BAD_ACCESS异常。特定错误指出com.apple.scenekit.renderingQueue.SCNView Thread 11崩溃。认为它与场景的复杂性有某种关系,我们将场景简化为三维盒子,应用程序仍然崩溃。呈现框的代码如下。崩溃似乎非常简单。并且非常奇怪的是,这在iOS9之前的所有内容上运行良好,并且在iOS9的模拟器上运行良好。它只在部署时崩溃。 (这是一个企业应用程序)。
崩溃发生在以下代码行: [scene.rootNode addChildNode:boxNode];
我错过了什么?谢谢你的帮助。
@implementation TreasureChestViewController
@synthesize sceneView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Create the SCNView
}
-(void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// Add scene an empty scene
scene = [SCNScene scene];
// Set the scene to the view
sceneView.scene = scene;
// Create and add a camera to the scene
SCNNode *cameraNode = [SCNNode node];
cameraNode.camera = [SCNCamera camera];
cameraNode.position = SCNVector3Make(0,15, 30);
[scene.rootNode addChildNode:cameraNode];
// Create and add a light to the scene
SCNLight *spotLight = [SCNLight light];
spotLight.type = SCNLightTypeSpot;
spotLight.color = [UIColor whiteColor];
SCNNode *spotLightNode = [SCNNode node];
spotLightNode.light = spotLight;
spotLightNode.position = SCNVector3Make(0, cameraNode.position.y, 20);
[cameraNode addChildNode:spotLightNode];
// A square box
CGFloat boxSide = 15.0;
SCNBox *box = [SCNBox boxWithWidth:boxSide
height:boxSide
length:boxSide
chamferRadius:0];
SCNNode *boxNode = [SCNNode nodeWithGeometry:box];
// boxNode.transform = CATransform3DMakeRotation(M_PI_2/3, 0, 1, 0);
[scene.rootNode addChildNode:boxNode];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
@end