I have a XIB viewcontroller with a button in it. I also have a storboard viewcontroller. I would like to know if there is a way to link a button from the xib view controller to the storyboard viewcontroller.
Asked
Active
Viewed 325 times
1 Answers
0
Short answer: No, not using interface builder.
You can do it in code though. Once you have the two view controllers instantiated just set the relevant property on your storyboard view controller.

Alfonso
- 8,386
- 1
- 43
- 63
-
Could you please explain to me in steps what I should do. Sorry I have recently started using xcode and I have made a game. I'm a 13 year old. – user3466875 Mar 30 '14 at 06:23
-
See [here](http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers) on how to pass variables between view controllers. The answer talks about `BOOL` variables, but works equally with objects. – Alfonso Mar 30 '14 at 07:29
-
Fonsi I know I have probably been annoying you with so many questions. Is there anyway you can send me an xcode project linking a button in a xib viewcontroller to a viewcontroller in storyboard and then a button in the viewcontroller in storyboard to go back to the viewcontroller in the xib? I'm really in need. My email is james.cusack0@gmail.com – user3466875 Mar 30 '14 at 19:48
-
Im so sorry if I have caused you any trouble. – user3466875 Mar 30 '14 at 19:49
-
This is all I need help with. After this I probably will not have any questions in the rest of my life. – user3466875 Mar 30 '14 at 19:50
-
You did not cause any trouble. Learning to code is a difficult (but rewarding) thing to do and having millions of questions is just normal. – Alfonso Mar 31 '14 at 07:45
-
I won't send you the project since you wouldn't learn from it. I recommend you read through [this](http://www.raywenderlich.com/50308/storyboards-tutorial-in-ios-7-part-1) tutorial (including part 2). It covers all the basics necessary to work with storyboards, including exactly what you asked for. You will benefit much more from this. – Alfonso Mar 31 '14 at 07:46
-
Fonsi I read this and used the navigation controller in my game. I disabled the navigation bar so It wouldn't look bad in my game. I did this by, I clicked on my menu view controller then went to Editor and embedded my menu viewcontroller in a Navigation controller. When you click the play button in the menu view controller I made a modal seague linking to the 2nd viewcontroller witch is the game. That works. But in my game I have a back button that I have added. I linked the back button to the Menu Viewcontroller with a modal seague and that works. But once you click the play button....... – user3466875 Apr 03 '14 at 01:43
-
and it goes back to the game for the second time my game glitches. By the way my game is like Flappy Bird. – user3466875 Apr 03 '14 at 01:43
-
But my game works perfectly fine the first time you click the play button and go to the game and play it. The problem is once you click the back button then click play again to pay the game a second time. – user3466875 Apr 03 '14 at 01:44
-
Did you also read part 2? It explains how to setup the "back" button in a modal view. You don't need to add another segue, instead you need to "undo" the first. – Alfonso Apr 03 '14 at 07:20
-
Dear Fonsi thanks for all your help. I looked at part 2 and it taught me that I had to create a unwind seague instead of using a modal seague to the first viewcontroller. – user3466875 Apr 06 '14 at 01:18
-
Now the only problem I have is that, I also have a restart button. And if I link the restart button in the Game Scene to the Game Scene it glitches just like how the home button used to. And I cant use an unwind seague cause and unwind seague is to go back to a scene not to the same scene. Do you have any solutions to this? Im am going to make seperate question for this and comment a link to it in a couple of minutes. – user3466875 Apr 06 '14 at 01:21
-
http://stackoverflow.com/questions/22888942/add-a-restart-button-to-my-storyboard-viewcontroller-to-link-to-its-self – user3466875 Apr 06 '14 at 01:29
-
Thanks for all of you guy's help. – user3466875 Apr 06 '14 at 02:30