Question

i have a situation like this one: example image

I have a first tableviewcontroller, with main categories; a second one with elements for each category; and a viewcontroller which show the content for each selected elements. I'd like to add in my viewcontroller a button-action or a swipe gesture, in order to change the view content to the next element content, without going back to the subcategory tableview and selecting another cell. I already know how to change view with button or gestures, but i'd like to know how to get 'next cell' (and previous one), inside the actual one. Thanks for any advice

Was it helpful?

Solution

The UITableView is a visual representation of your datasource, let's say an NSArray of NSDictionary objects. So it seems obvious that your UIViewController is a detail representation of the same datasource. So you could pass this array and the indexPath of the selected cell in tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath to your viewcontroller and store it for further use. When you swipe left / right you just increase / decrease the selectedIndex and display your datasource's content.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top