the main tableview will have rows that is added/created from the user and that row will open their own tableview which also have their own add/create own row. My main question is how to make sure each row thats added in the main tableview opens their own tableview (as blank until added from user).
This link i’ve seen is the closest How can I move to another view controller when the user clicks on a row? but not exactly what Im looking for. Most of the samples/tutor is all ususally populated or already have an array in their tableview. I wanted to make mines both completely nothing in it but added only by the users and main tableview each row opens its own tableview.
I already have two tableview one is main and other is sub to each row. I was able to insert row in main table view but it opens the same tableview as the other rows in the main tableview and would like to know how to make sure each row in main tableview opens their own blank tableview.
Usually your view controller controls the tableView. I guess you are trying to fit in there multiple table views and logic for each one. Instead, just create controllers for each table.
First create your main view controller using a UIViewController template (don’t use a TableViewController). Use a XIB and add there a TableView element, OR create a UITableView instance using code.
Now create a class conforming to the delegate and datasource, protocols. This doesn’t need to be a view controller. Example:
// MiniTVC.h
and implement the delegate and datasource methods as usual. You need at least the following:
tableView:heightForRowAtIndexPath:numberOfSectionsInTableView:tableView:numberOfRowsInSection:tableView:cellForRowAtIndexPath:Then back to your main view controller, you create (or hook from the interface designer using IBOutlets) a tableView and set its delegate and datasource to your MiniTVC class, eg:
You can repeat this process creating another UITableView + MiniTVC from inside a custom UITableViewCell. Or you could make the UITableViewCell conform to the table delegate/datasource and implement there the methods.
Btw, creating tableviews inside tableviews is a bit unusual. Since they are both UIViewScroll subclasses, it could lead to unexpected behaviour, tho I haven’t tried myself.