Push different ViewControllers for every cell in a sectioned UITableView - 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

Related

UITableViewCell into multiple View Controllers

I started to develop an app that use two view controllers (VCs). For each VCs I use a uitableview that use the same uitableviewcell. My ask is if exist a same queue between uitableview where to use a uitableviewcell between two view controllers or if i should create a custom queue where i can to reuse the contentview of uitableviewcell
More graph
VC1 - UITableView1 -> UITableViewCell1
VC2 - UITableView2 -> UITableViewCell1
I would like to reuse the UITableViewCell1 in both tables and decrease the use of memory.
pd: the navigation between these vcs is with a uinavigationcontroller.
Thx
Yes. You can do it by creating Custom Table View Cell and Use it in all table views.
I'd added solution for the same kind of issue on Collection View.
You just refer the same for your Tableview. You just repeat the same with Tableview cell.
Common Collection View Cell in all collection Views
Hope it helps.

Segue between multiple detail views when selecting from tableview

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

How to segue from xib file uiview to storyboard ViewController

My program does not have an explicit table. It’s only table comes from “Search Bar and Search Display Controller” view as searchDisplayController.searchResultsTableView. So to create it’s custom TableViewCell, I use a xib file. Now I need to segue from the custom cell defined in the xib file to a ViewController defined in the storyboard? How do I do that?
stated differently: How to segue from a custom TableViewCell of “searchDisplayController.searchResultsTableView” to a ViewController
back story How do I add storyboard-based Header and CustomTableCell to a “Search Bar and Search Display Controller”
There seems to be an answer already but I don't get it: Segue from Storyboard to XIB
As with any table view, you should be able to set the UITableViewDelegate and UITableViewDatasource delegates on the searchDisplayControl class. And then handle segue event in the didSelectRowAtIndexPath method. I've never played with search display controllers as I typically break apart search bar and table views when I do anything search related for the sake of flexibility, and how you're saying you want to use prototype table view cells in a tableview within the storyboard.
But, if you're set on using the searchDisplayController, you could possibly get away with something like this..
You can't segue from one XIB -> Storyboard, or between 2 different storyboards.
You can pass a reference to the viewController to each tableViewCell, and access the segue that way if you'd like. However, I'd probably use protocols/delegates personally in this situation for the sake of future flexibility.
As we discussed in comments above, it's better to avoid UISearchDisplayController since it's deprecated in iOS 8.
So it would be better to use something like that https://github.com/alexbutenko/SimpleUITableViewSearch
You can use self.navigationItem.titleView = searchBar to embed search bar into navigation bar. If you have any issue just check code sample.

set size of tableview in ios storyboard

I want my ViewController to be shared by a tableView and a TextView, where the TextView would appear beneath the TableView. But the TableView insists on taking over the entire scene/screen. How do I set the height of the TableView in the storyboard so I can make room for my TextView? (Please notice that I am not asking for a footer, which is actually what I am trying to change from)
The problem is that you are using a UITableViewController, which means that you get a scene with a full-screen UITableView.
To avoid this, use a normal UIViewController scene and just insert the UITableView into the interface manually (and configure its delegate and dataSource to point to the view controller).
UITableViewController is just a convenience. It doesn't do anything for you that you can't do yourself with a normal UIViewController. And in your situation, it is an inconvenience instead of a convenience.
Add a container view to your ViewController and link to an "external" UITableView instead of the provided UIView that comes with it when your drop it into your storyboard.
Send data via the segue, get it back via a delegate.
This way you can freely design your View with very little headaches.

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!

Resources