0

I have implement UISearchController in my HomeController.By this way

SearchTableViewController *searchResults = (SearchTableViewController *)self.controller.searchResultsController;
[self addObserver:searchResults forKeyPath:@"myResult" options:NSKeyValueObservingOptionNew context:nil];
searchResults.rootHomeController=_homeController;
[self presentViewController:self.controller animated:YES completion:nil];

My Search value showing well in SearchTableViewController.Now I need to go details after SearchTableViewController UITableView cell click i tried by this way but not working.

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:
                                @"Main" bundle:[NSBundle mainBundle]];
AlbumSongListController *detailSongList=[storyboard instantiateViewControllerWithIdentifier:@"AlbumSongListControllerID"];
    [self presentViewController:detailSongList animated:YES completion:nil];

I need to pass navigation controller so that i can back to search controller

aDowla
  • 61
  • 6
  • can you elobrate need to pass navigation controller so that i can back to search controller – Anbu.Karthik Aug 08 '16 at 06:35
  • when i click on search tableview row i can go details view fine .but i want to add navigation back button so that i can comeback to searchviewtable controller – aDowla Aug 08 '16 at 06:38
  • plz check my answer @aDowla – balkaran singh Aug 08 '16 at 06:40
  • then in this place `[self presentViewController:detailSongList animated:YES completion:nil];` use [Self.navigation Controller pushviewcontroller: detailSongList animated :YES]; – Anbu.Karthik Aug 08 '16 at 06:40

3 Answers3

0

pass your result one view controller to another by declaring a varialble like:

let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
                    let resultViewController = storyBoard.instantiateViewControllerWithIdentifier("DestViewController") as!  DestViewController
                    resultViewController.result = self.result
                    self.presentViewController(resultViewController, animated:true, completion:nil)
Chirag Patel
  • 1,453
  • 1
  • 11
  • 21
  • questioner tagged as objective C at the same time how do we create `result` in `resultViewController`, can you updated the answer with details – Anbu.Karthik Aug 08 '16 at 06:28
  • declare a result variable to your destination view controller and pass your source view controller result to destination view ontroller – Chirag Patel Aug 08 '16 at 06:29
  • @ChiragPatel - I know biddy, assume that qustioner is fresher how he anaylize your answer is corerct – Anbu.Karthik Aug 08 '16 at 06:30
0

plz use this code in app delegate

 -(BOOL) application: (UIApplication * ) application didFinishLaunchingWithOptions: (NSDictionary * ) launchOptions {
    UIStoryboard * storyboard = [UIStoryboard storyboardWithName:
        @ "Main"
        bundle: [NSBundle mainBundle]
    ];

    HomeVcController * HomeVcControllerOb = [storyboard instantiateViewControllerWithIdentifier: @ "HomeVcControllerID"];

    UINavigationController * navController = [
        [UINavigationController alloc] initWithRootViewController: HomeVcControllerOb
    ];
    self.window.rootViewController = navController;

}

and hidden NavigationBar on homeVWcontroller

[self.navigationController setNavigationBarHidden:YES animated:YES];

then after just use this

UIStoryboard * storyboard = [UIStoryboard storyboardWithName:
    @ "Main"
    bundle: [NSBundle mainBundle]
];

AlbumSongListController * detailSongList = [storyboard instantiateViewControllerWithIdentifier: @ "AlbumSongListControllerID"];

[self presentViewController: detailSongList animated: YES completion: nil];

and in AlbumSongListController show navigation bar

[self.navigationController setNavigationBarHidden:No animated:YES];
Raymond
  • 2,276
  • 2
  • 20
  • 34
balkaran singh
  • 2,754
  • 1
  • 17
  • 32
0

You need to present a navigation controller with SearchTableViewController as root in your HomeController. Thus you can perform navigations.

i.e. on click of table cell in SearchTableViewController (didSelectRowAtIndexPath delegate), push the detail view controller using [self.navigationcontroller pushviewcontroller] , you will get back navigation to SearchTableViewController by doing so.

Annie Dev
  • 282
  • 1
  • 10