Segue between multiple detail views when selecting from tableview - ios

Ok, I haven't been able to find a definitive answer to this. I'm on Xcode 6 working with Swift and a UISplitView. I have multiple detail views in storyboard and I want to be able to replace my detail view with another when selecting from a tableview. In Xcode 5, I was able to drag multiple segues from my prototype cell and use performSegueWithIdentifier. In Xcode 6, I can only have one segue coming from my prototype cell.
What's the best way to go about this?

One type of cell, one segue. This seems to be a logical and useful system constraint.
One solution is to just create more cell types with different cell identifiers.
Alternatively, if you have another way to determine which segue to use, draw all segues from the view controller instead of the cell. You can attach the necessary row object information in the sender object when calling the segue from the cell selection method.

You can create as many segues as u want from viewcontroller and give each seuge an different segue Identifier in IB, and the call each with performSegueWithIdentifer method

Related

iOS Different Views for Table View Cell items

I just started iOS development last week and I am creating a Table View based application. I having trouble understanding how to use storyboard.
I want each Table Cell to open a different ViewController.
Currently it is setup like this:
Then in the Component View Controller I use if/else statements to determine what content to load. The problem occurs when one of the views needed a TabBar.
How do I assign different View Controllers to each individual cell, rather than one "template" view and forced to add everything dynamically.
First off, I will say that it probably isn't the best idea to assign an individual view per cell. However, if it is what you wish to do, then so be it.
What you would do is create a segue from the table view to the new view by clicking on the table view icon and dragging a segue like so:
2.You would give that segue an identifier like "embedTweetsSegue" or something.
You can then check for the cell being touched and perform the segue programmatically using:
performSegueWithIdentifier("embedTweetsSegue", sender: self)

how to implement multiple segues using dynamic cells in Xcode?

i have a table view with dynamic prototype cells divided into 2 different sections named "Forums" and "Threads". When i click on a tableview cell from the Forums section, i want to transit to the same page with a different data to display while if i click a cell from the Threads section, it should open a different scene. In short, two different types of transition segues from 2 different tableview sections)
Can anyone please help me with this?
Make sure the table view controller is embedded in a navigation controller.
Hook up two push segues to the table view controller (not to the cells).
Give those segues appropriate identifiers in the storyboard using the attributes inspector tab on each segue.
In -tableView didSelectRowAtIndexPath: add an if statement to detect which section the row tapped was in.
In the branches of the if statement, call -performSegueWithIdentifier on your controller using the identifier of the appropriate segue .
If you need to set up anything in the view controller you're seguing to from the table view, override prepareForSegue: sender: in the table view controller.
Very helpful, it worked for me, but I had to used BOTH didSelectRowAtIndexPath AND prepareForSegue, while I was reading in other posts that this is not very good.
I read that we need to use only the prepareForSegue if we need to set up any stuff...
Do you think that I should continue with both of them?
Thanks!

Push different ViewControllers for every cell in a sectioned UITableView

I have a UITableView with sections for different alphabets. I want each cell to push a different ViewController. Is it possible?
Simply use Storyboard, Control drag from each cell to the the ViewController you want it to attach. Make the segue type to "Push"
If your using storyboards, here's a possible solution: http://forums.macrumors.com/showthread.php?t=1274743

Different Segues from Different UITableViewCells?

This appears to be a storyboard editor issue because it's easy to do in code.
I have a UITableView with two different prototype cells. They have reuse identifiers, different accessories. I want selecting one type to trigger a segue to another view controller, and selecting the other to go to a different view controller. But as soon as I create the second segue in the storyboard editor, the first one is replaced. Even if I have named it.
It seems this should be a common enough scenario, I should be able to have multiple segues, and differentiate them in prepareForSegue.
I need to note, this is easy to do in the didSelectRowAtIndexPath for the view controller's table view delegate, but there I have to explicitly load the template from the storyboard (unless I use a generic and don't need a nib).
Has anyone been able to get this to work in the storyboard editor?
The only way I could think of to do this with how things currently work is by using two different types of prototype cells. (two separate classes) and assigning each different segue to each different subclassed prototype cell.

Issues using custom iOS UITableView cells / "Multiple segues with identifier" error

I have created a Table View that has multiple Table View Cells of different styles - say "CellStyle1" and "CellStyle2".
The cells look different, but they should perform the same when selected - namely, segueing to the same new view.
I have set up both cells to have the same Storyboard Segue - "PushView", pointing to the same view controller.
This seems to work OK, but Xcode generates a warning: "Multiple segues with identifier"
How can I avoid this error? What is the right way to handle multiple custom cells that look differently but act the same and should segue to the same place?
This one has me scratching my head.
Thanks!
You could make one segue by ctrl dragging from the view controller to the destination view controller. And then assuming tapping the cell is the event that you want to trigger the segue, in didSelectRowAtIndexPath call performSegueWithIdentifier.
- (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender
Or just give the 2 segues different identifiers and in prepereForSegue check for either identifier.

Resources