问题描述
首先,我不得不说,有这个平台上如此多的信息,因为每个人的,是谁帮助。非常感谢你。
目前,我已经到了,在这里我不能再往上我自己的。
这是我的问题:
我有一个MainScreen的ViewController这是在导航控制器镶嵌。
从这个MainScreen,我可以用Segue公司将创建一个Gamescene一个GameViewController显示。
在这个Gamescene,我有一个按钮,当它被窃听,显示弹出并暂停Gamescene。
此弹出包含两个按钮:
- A键恢复比赛,并在弹出的消失。
- 一个按钮,应该结束了Gamescene并返回到Mainscreen。
这里是我的问题。
我不能创建结束按钮的功能。我曾尝试与塞格斯不同的星座,但它没有好下场的。
我觉得这里的困难是,这个按钮是在单独的类。这里的层次,按照我的理解,应该是:
GameViewController - > GameScene - >弹出 - > EndButton
你有任何想法我怎么能解决这个问题?会有解决这个转变不使用塞格斯的其他方式?
非常感谢您对您的帮助提前!
亲切的问候,
菲尔
更新:
在我Gamescene弹出基本上是这样的:
类GameScene:SKScene,SKPhysicsContactDelegate { // ....
VAR暂停按钮:UIButton的! =的UIButton()
VAR pausePopup:PausePopup! //我的弹出类结束按钮
// .... 覆盖FUNC didMoveToView(查看:SKView){ //配置按钮
pause_button.addTarget(个体经营,动作:暂停按钮pressed,forControlEvents:UIControlEvents.TouchUpInside) self.view?.addSubview(pause_button) } FUNC暂停按钮pressed(){
self.pausePopup = PausePopup(nibName:uxPausePopup,捆绑:无)
self.scene!.view!.paused =真
self.pausePopup.showInView(self.viewPlaceHolder,动画:真实,场景:个体经营)
}
//这是我的弹出窗口将会出现在哪里。
在我弹出类我有它位于弹出式窗口,从中我想返回到主屏幕EndButton一个动作:
@IBAction FUNC showMainScreen(发件人:AnyObject){
//这不工作...
self.performSegueWithIdentifier(showMainScreen,发件人:无)
}
您不能调用从showInView另一种观点,则需要关闭该酥料饼和GameScene调用MAINVIEW,这样做,你可以在你PausePopup创造一种竞争的处理程序或协议来你的酥料饼到GameScene交易的结果传递的结果。
First of all, I have to say that there is so much information on this platform, because of everyone, who is helping. Thank you very much.
At the moment, I have reached a point, where I am not able to go further on my own.
This is my problem:
I have a MainScreen ViewController which is embeded in a Navigation Controller.From this MainScreen, I can show with a Segue a GameViewController which creates a Gamescene.In this Gamescene, I have a button, which when it is tapped, shows a Popup and pauses the Gamescene.
This Popup contains two buttons:
- A button to resume the game and make the popup disappear.
- A button which should end the Gamescene and return to the Mainscreen.
And here is my problem.I am not able to create the function for the End Button. I have tried different constellations with segues, but it didn't end well.
I think that the difficulty here is, that this button is in an separate class. The hierarchy here, as I understand it, would be:
GameViewController -> GameScene -> Popup -> EndButton.
Do you have any ideas how I could solve this problem? Would there be an other way to solve this transition without using segues?
Thank you very much for your help in advance!
Kind regards,Phil
Update:
In my Gamescene the popup basically looks like this:
class GameScene: SKScene, SKPhysicsContactDelegate {
// ....
var pauseButton : UIButton! = UIButton()
var pausePopup : PausePopup! // my Popup class with the End button
// ....
override func didMoveToView(view: SKView) {
//configuring the button
pause_button.addTarget(self, action: "pauseButtonPressed", forControlEvents: UIControlEvents.TouchUpInside)
self.view?.addSubview(pause_button)
}
func pauseButtonPressed() {
self.pausePopup = PausePopup(nibName: "uxPausePopup", bundle: nil)
self.scene!.view!.paused = true
self.pausePopup.showInView(self.viewPlaceHolder, animated: true, scene: self)
}
// this is where my popup appears.
In my Popup class I have an action for the EndButton which is located on the Popup and from which I would like to return to the main screen:
@IBAction func showMainScreen(sender: AnyObject) {
// this does not work ...
self.performSegueWithIdentifier("showMainScreen", sender: nil)
}
You cannot call other view from showInView, you need to dismiss the popOver and call the mainView from GameScene, to do so you can create a competition handler in your PausePopup or a protocol to pass the result of your popOver to GameScene deal with the result
这篇关于斯威夫特的iOS:在的ViewController到另一个的ViewController从实例执行Segue公司的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!