I am trying to develop a Table View Controller,where rows are connected to multiple View Controllers
(TextField,TextView,TableView,DatePicker,ImageView etc.).
So if I click on any row,it should open the Intermediate View
and place the appropriate controller in a common place where rest of the thing will be same for all controller.Suppose I clicked on a row where the index is mapped to TableView.When It will open the Intermediate Controller, It should placed the tableview in the common container,this table view should come from a single TableView controller for all other Tableview.
I am new in ios and not able to design this.
What is the best way to design this? How do I implement this?
Thanks
I would suggest that don't create cell in Storyboard and connect it. Instead leave empty table in storyboard and create cell using code. You can create custom cell by subclassing
UITableViewCell
.In storyboard you just link table view with all view controller using segue and give it proper identifier name.
Now implement all delegates methods of
UITableView
. Override-tableView:didSelectRowAtIndexPath:
method and on row selection perform segue for specific row.Example:
Here in above case if you select first row it will push view controller which is connect with
BasicCoreDataSegue
segue in Storyboard, you can compare it with image.Using similar way create other segues and call them in
didSelectRowAtIndexPath
method in different switch case.Also If you want to pass any values to push controller, override below method:
Edit:
Above code works for common controller. Now you don't need to create more segues also in
didSelectRowAtIndexPath
method set Intermediate controller segue.Use
[self.tableView indexPathForSelectedRow]
method to get selected row inprepareForSegue
method.For Example:
Now when
prepareForSegue
is called then set integer value for Intermediate controller.In above code
selectedIndex
is a integer variable which is used to track that which row is selected.Now in Intermediate controller in
-viewDidLoad()
use switch case to get controller object which you want from row selection and add its view as a subview in Intermediate Controller.