Reputation: 547
I'm little lost here. I have a basic master-detail aplication, and I want to change the detail view according to the selected row in MasterViewController, but the views have different content, one has an image gallery, and the other one will load a video on full screen. It's not just refresh the detail view, have to load another view. How is the better(fast) way to do that?
Upvotes: 12
Views: 8970
Reputation: 628
If you are using a dynamic tableview in your MasterViewController, implement numberOfRowsInSection:(NSInteger)section Method with:
return [_youDataArrayNameHere count];
then on cellForRowAtIndexPath configure the cell:
cell.textLabel.text = [_youDataArrayNameHere objectAtIndex:indexPath.row];
and in didSelectRowAtIndexPath, call any other view based on the selected row:
//
if (indexPath.row == 0) {
[_detailViewController.navigationController pushViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"anotherVC01Here"] animated:YES];
}
Upvotes: 1
Reputation: 13386
I'll suggest you to use a replace segue.
Just create a segue to the desired view initiated by your row with a Style: Replace, and Destination: Detail Split.
Segues were introduced in the iOS 5 SDK
EDIT:
These are step-by-step instructions to accomplish what you need. From now on:
just a bit for naming for ease of explanation
That's all.
More on segues: http://www.scott-sherwood.com/?p=219
Upvotes: 17
Reputation: 202
Specifically, in CS193P, check out the latest version, and look at lecture #7. Paul doesnt finish the part with the replace Segue, but he DOES provide an example with very good reusable code (Psychologist with Dr Pill)
Upvotes: 1