Change detail view from MasterDetail iPad app using storyboard
Asked Answered
B

3

12

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?

Brick answered 19/2, 2012 at 19:36 Comment(0)
H
17

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:

  • the item that should be pressed for the action to take place (a button or row in master view) = *Button;
  • the view you want to be placed in the iPad's detail view = *Detail.

just a bit for naming for ease of explanation

  1. Hold ctrl click on *Button then hold and drag to *Detail and release to create your segue.
  2. In the popup pick Replace
  3. Select your segue, open Attributes inspector and set Destination to Detail Split

That's all.

More on segues: http://www.scott-sherwood.com/?p=219

Harlie answered 19/2, 2012 at 21:59 Comment(8)
Still cant understand, so far all examples ive seem the detail view is, always have the same content,changing only one image or some text.Do you have any example or tutorial on how to do that you just said?Iand
@user1108474 do you know what is iTunes U? It has very nice stanford classes on iPhone and iPad development. Also you can check our the next app: stanford.edu/class/cs193p/cgi-bin/drupal/system/files/… the thing that you need is done by Dr Pill view (when u press the buttons). Also I'll add more detailed description in my answerHarlie
Uko... you're the man! You saved my bacon! I have been fighting this for 3 days now, nobody seems to either know the answer, or cares to answer. I truly appreciate your time answering this. Regards, Spokane-DudeOodles
You are welcome! Have a nice day :) By the way, can you mark this answer as correct?Harlie
I found almost nothing about replace segues. Are they limited to split view controllers? I have a pane in my iPad app the content of which must change depending on which button is pressed. It doesn't use a master-detail UI. Can I use a replace segue to switch the pane view? If not, what would be the best way to storyboard that? Thanks.Polychrome
@Jean-DenisMuys yes, ass far as I know replace type of segue is specific to split view controller. Your comment qualifies for another question, but what can I suggest 1) use a split view controller 2) use some method or other stuff to change the content 3) generate instantiate needed controller on the go.Harlie
I now have a split view controller and this works... except that the replaced detail views do not have the navigation bar, thus no popover button. Any idea what I missed?Polychrome
@Jean-DenisMuys is the navbar a part of navigation view controller or I've added it just as a subview? It's it's a part of nav-view controller then be sure that you're segueing into it an not into some of it's sub controllers. If my suggestion won't solve your problem please try to be more specific. Maybe you should ask another question about this to be able to describe your problem in details.Harlie
R
1

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];
}
Reciprocity answered 19/2, 2012 at 19:36 Comment(0)
S
1

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)

Sizing answered 6/4, 2012 at 16:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.