Cocoa touch 什么时候应该使用pushScene和ReplaceSene?
我使用cocos2d,我使用pushScene和ReplaceSecene移动到下一个场景。但是,我不知道我们应该用哪一个 当我在某些地方使用ReplaceSecene时,应用程序崩溃并出现错误,如Cocoa touch 什么时候应该使用pushScene和ReplaceSene?,cocoa-touch,cocos2d-iphone,Cocoa Touch,Cocos2d Iphone,我使用cocos2d,我使用pushScene和ReplaceSecene移动到下一个场景。但是,我不知道我们应该用哪一个 当我在某些地方使用ReplaceSecene时,应用程序崩溃并出现错误,如 -[UITextView length]: unrecognized selector sent to instance 0x842a750 Terminating app due to uncaught exception 'NSInvalidArgumentException', reas
-[UITextView length]: unrecognized selector sent to instance 0x842a750
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UITextView length]: unrecognized selector sent to instance 0x842a750'
但是,在我的程序中,我没有将长度传递给UITextView。我的程序就是这样的在场景1中,我有UITextView,我将用场景2替换此场景。然后
-(id)buttonPressed:(id)sender
{
[description removeFromSuperview]; // It is the textView(description)
CCScene *Scene = [CCScene node];
CCLayer *Layer = [scene2 node];
[Scene addChild:Layer];
[[CCDirector sharedDirector] setAnimationInterval:1.0/60];
[[CCDirector sharedDirector] replaceScene: Scene];
}
但是,当我在replaceScene面前使用pushScene时,它工作得很好。请澄清在哪些情况下应该使用哪一种
谢谢您将希望在几乎所有情况下使用ReplaceSecene。pushScene方法将前一个场景保留在内存中,这很可能是它没有崩溃的原因。该场景有些地方不太对劲,当它在替换场景后解除分配时,崩溃就发生了。它与cocos2d的替换场景系统无关 场景1中的UITextView可能发布得太频繁。如果将其创建为自动释放对象,则不要向其发送释放消息