Vista dividida de iOS - Vista detallada de recarga

I am new to making iOS apps. I have currently built a Split View based app. There is an array in the left had table and what ever is touched it loads the relating xib file in the detail view.

Now I want a home button to work. I want this to basically reload the DetailViewController to scratch. I have got it working like this so far:

- (IBAction)homeButtonPressed:(id)sender;
{


    [[NSBundle mainBundle] loadNibNamed:@"DetailView" owner:self options:nil];//load xib
    self.navigationItem.rightBarButtonItem = nil;//hide the home button
    [self setTitle:@"Driveway Code"];//display the title
}

But the problem with this is that it still has the row selected in the left hand side. And I cannot seem to un select it.

If you could provide me with help either to reload the split view again or to just unselect the row. I would be happy. Thanks :)

ACTUALIZACIÓN:

I have now go this:

- (IBAction)homeButtonPressed:(id)sender;
{



    [[NSBundle mainBundle] loadNibNamed:@"DetailView" owner:self options:nil];
    self.navigationItem.rightBarButtonItem = nil;

    [self setTitle:@"Driveway Code"];
    DetailViewController *dvc = [[DetailViewController alloc] init]; [dvc setTableView:tableView];

    [tableView deselectRowAtIndexPath:detailItem animated:YES];



}

preguntado el 27 de agosto de 11 a las 14:08

1 Respuestas

Use this method to select row programmatically:

- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UITableViewScrollPosition)scrollPosition

and this one for deselect

- (void)deselectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated

Respondido 27 ago 11, 18:08

Thanks, but I cannot seem to implement this into my DetailViewController.m. Please could you show me? Thanks. :) - Ryryan

You should have the reference to your table view tableView in DetailViewController and when you need just call [tableView deselectTowAtIndexPath:[tableView indexPathForSelectedRow]]; - Nekto

No, unfortunately I haven't got that. Where should this be and how shall the code look? :/ - Ryryan

Definir @property (nonatomic, retain) UITableView *tableView; in DetailViewController.h. In @implementation DetailViewController escribir @synthesize tableView;. And, finally, when after initializing DetailViewController escribir DetailViewController *dvc = [[DetailViewController alloc] init]; [dvc setTableView:tableView]; where tableView is your left table view =) - Nekto

Thanks. But I am having issues adding the last line. In the detailviewcontroller.m it isn't accepting. Where's the initialisation? - Ryryan

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.