将重新启动按钮添加到我的故事板视图控制器以链接到其自身 [英] Add a restart button to my storyboard viewcontroller to link to its self

查看:44
本文介绍了将重新启动按钮添加到我的故事板视图控制器以链接到其自身的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的故事板中有一个游戏视图控制器.我添加了一个重新启动按钮并将其链接到同一个视图控制器,这样当玩家死亡时,他们可以单击该按钮,游戏将重新开始.我的问题是,当您单击它并重新启动时,游戏开始出现故障.任何建议或解决方案.我不能使用放松海格,所以我该怎么办.

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.

推荐答案

这实际上取决于您的代码,特别是在您的 viewDidLoad 中.

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

在视图的类文件中为该重启按钮创建一个 IBAction.

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

对于 .m 文件中的 IBAction 方法,请尝试以下每一行不同的代码:

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

[super viewDidLoad];

,

[self.view setNeedsDisplay];

[self.view setNeedsLayout];

告诉我它是否有效,或者如果您有任何问题.

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

这篇关于将重新启动按钮添加到我的故事板视图控制器以链接到其自身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆