0

I want to create a segue from (a) a UIButton (in a custom cell of a tableview) and (b) a custom cell in general to a UIViewController. The custom cell is specified in a .xib file. I read that I just should control drag from the UIButton / custom cell to the UIViewController. That doesn't work for me.

  1. The .xib file of the custom cell isn't inside the storyboard - that's right? I thought about that it should be inside the storyboard. If necessary, how can I do that?
  2. How can I create a segue from the UIButton (in a custom cell) / custom cell to the UIViewController?

Thanks!

EDIT: I'm using a UITableViewController as Source, the destination is a UIViewController with a UITableView.

Joe
  • 207
  • 1
  • 2
  • 9

2 Answers2

0

Ctrl-drag from the tableViewController (not from the prototype cell) to your target viewController and assign an identifier name to the segue.

Now override didSelectRowAtIndexPathto perform the segue with your identifier when tapping that cell:

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)    
{
    performSegueWithIdentifier("yourSegue", sender: nil)
}

Distinguish between the cells based on your indexPath and create as many segues as you need to your target viewControllers.

You can do similar for the button in your custom cell. Perform the segue on the button's action.

zisoft
  • 22,770
  • 10
  • 62
  • 73
  • If I select the tableViewController and Ctrl-drag to the viewController the menu doesn't appear. I don't know why, it's appearing if I Ctrl-drag from a barButtonItem.. – Joe Sep 09 '14 at 21:41
  • Try dragging from the IB content pane on the left side – zisoft Sep 10 '14 at 06:21
  • You mean in the document outline, select the correct scene and the TableView and Ctrl-drag from there to the UIViewController?! I tried that before, it doesn't work. – Joe Sep 10 '14 at 07:21
  • Yes, but from the TableViewController, not the TableView. – zisoft Sep 10 '14 at 07:40
  • Doesn't work either - am I doing something wrong? :/ – Joe Sep 10 '14 at 09:20
0

I used xcode6beta5 that should be the problem. Now I'm using xCode6 GM and the creation of the segues works absolutely fine like zisoft wrote! Thanks man!!

Joe
  • 207
  • 1
  • 2
  • 9