1

I'm stuck because of this problem in my code:

I am using a storyboard, and have my custom tableview that is able to swipe rows uncovering the "background" where I can add buttons etc. Problem is that the number and presence at all is managed in runtime (each cell can have multiple buttons or none - I'm adding them to the background view). Now I want these buttons to segue and I just cannot figure out how to do it in my storyboard... Anyone had similiar problem or I'm just thinking wrong?

pawel.gil
  • 13
  • 1
  • 3

3 Answers3

3

Another way to do this is to go ahead and create the segue's in the storyboard. You can't connect them to the button (since it doesn't exist yet), but you can connect them to the view that the table is in. You give the segue an identifier (by clicking on the line that is the segue and setting the property). Then, it is a simple matter of calling:

[self.storyboard performseguewithidentifier:@"theIdentifier"];
lnafziger
  • 25,760
  • 8
  • 60
  • 101
  • Yeeeaah... Well - I solved this by creating custom segue (pulled from controller icon in storyboard), and fireing it from my code inside onButtonTap. Pretty simple and straightforward. – pawel.gil Jan 22 '13 at 19:28
  • this sounds pretty genius if it works, but wouldnt this mean if the user clicked anywhere inside the view where the tableview lives it would activate this segue? – ChuckKelly Dec 24 '13 at 19:53
  • @ChuckKelly: Nope, it only fires automatically from controls. – lnafziger Dec 24 '13 at 20:08
2

you can't make segue connections outside of the storyboard:

Creating a segue programmatically

You can make custom segues in code, but connecting the segues up to objects can only be done by drawing lines on the Storyboard.

But you don't need to. Segues are only dressed-up transitions between viewControllers. They are a visual tool for replacing a small amount of code.

A push segue just replaces this code for example

UIViewController* myViewController = [UIViewController alloc] init;
[[self navigationController] pushViewController:myViewController

As you are making your buttons in code, you should manage your navigation in code.

Community
  • 1
  • 1
foundry
  • 31,615
  • 9
  • 90
  • 125
1

First of all you need to set the StoryBoard ID. You can do this by selecting a particular view controller and going identity inspector on the right side. Under the custom class, there is "StoryBoard ID", you have to set name "Menu"

enter image description here

Secondly, you need to call this storyboard from the buttons or any other control.You can do this by using the following:

[self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];

This way you can give StoryBoard IDs to different controllers in your StoryBoard and call them from whatever control you want.

Hope this helps

Jessica
  • 1,508
  • 15
  • 25