I have a standard UIViewController (TestViewController), and in this controller's viewWillLayoutSubviews method I instantiate a new SKView subclass (TestView) and add it as a subview to the controller's view. In addition I add some buttons which are meant to let the user control actions in an SKScene subclass (TestScene). TestScene is instantiated in an init method on TestView. Immediately after TestView is added to TestViewController's view as a subview I also call [testView presentScene] which is a method on the TestView that simply calls [self presentScene: testScene].
Pressing the mentioned buttons on TestViewController is meant to call a method on TestScene (via TestView) that will instantiate a new SKSpriteNode subclass (TestSpriteNode) and add it as a child to the scene. This does work, but my problem is that for the first TestSpriteNode to get added there is intermittently a long delay in the TestScene rendering the new sprite. From time to time it works perfectly but most of the time it will get stuck and after multiple touches of the button multiple sprites will appear all at once, after which everything functions perfectly. I should mention that this problem occurs on the simulator as well as on my device.
I have tried adding a new TestSpriteNode in the TestScene's -(void)didMoveToView:(SKView*)view resulting in the TestSpriteNode appearing immediately and then there being a delay when the button is pressed to add a new TestSpriteNode. By adding a break point to the method that the button press calls on TestScene I can see that it is called immediately but the added TestSpriteNode is not rendered immediately.
I apologise in advance if there is already an answer that addresses delays in rendering dynamically added SKSpriteNodes, I was not able to find it. Is there something that I have misunderstood about adding new SKSpriteNodes to an SKScene?