Add a restart button to my storyboard viewcontroller to link to its self

↘锁芯ラ 提交于 2019-12-25 05:11:49

问题


I have a viewcontroller in my storyboard that is a game. I have added a restart button and linked it to the same viewcontroller so that when the player dies they can click that and the game will start all over again. My problem is that when you click it and it restarts the game starts glitching. Any suggestions or solutions. I cant use a unwind seague so what should I do.


回答1:


It really depends on your code, specifically in your viewDidLoad.

Create an IBAction for that restart button in your view's class files.

For the IBAction method in your .m file, try each of these different lines of code:

[super viewDidLoad];

,

[self.view setNeedsDisplay];

, or

[self.view setNeedsLayout];

Let me know if it works, or if you have any questions.



来源:https://stackoverflow.com/questions/22888942/add-a-restart-button-to-my-storyboard-viewcontroller-to-link-to-its-self

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!