Search code examples
iosxcodeuisplitviewcontrolleripad

how to update the uitablview of detailview on row select of master view or load new view in detailview?


am using xcode and developing one master detailview app for ipad

my requirement is there is two tablview ..one for masterviewcontroller and 2nd for detailview controller

and on select row of masterview i want to change the tableview data of detailview or another way is to reload new view controller in detailview..

so can anyone please tell me..how can i do that? or can anyone provides me tutorial for that ?

i have tried to goggle the things but didn't succeeded.

i have tried to push new view controller on click of masterdetailview tableview cell with following but its navigating the masterdetailview to my new viewcontroller..but what i want is to navigate from detailview controller to new view controller after click on master detailview table row

StatusesTableViewController *statusviewController = [[StatusesTableViewController alloc] initWithNibName:"StatusesTableViewController" bundle:nil];



    [self.navigationController pushViewController:statusviewController animated:YES];
    [statusviewController release];

Solution

  • In the MasterViewController.m

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
        DetailViewController *detailViewController = [[DetailViewController alloc] init];
        detailViewController.arrData = //YOUR ARRAY
        [self.navigationController pushViewController:detailViewController animated:YES];
    }
    

    in DetailViewController.m

    in (void)viewDidLoad

    tableView.delegate = self;
    tableView.dataSource = self;
    [tableView reloadData];
    

    And implement required delegate and datasource method of the DetailViewController.m with your array.