-1

I went from one ViewController to another using Segue in my second viewController has an UITableView. now, I want to push from second ViewController's didSelected method to another viewController.

code use to Segue:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

self.view.backgroundColor = [UIColor clearColor];
self.modalPresentationStyle = UIModalPresentationOverCurrentContext;

SearchVC *svc = segue.destinationViewController;
self.providesPresentationContextTransitionStyle = YES;
self.definesPresentationContext = YES;
}

under button action:

-(void) searchButtonClicked:(id)sender {
[self performSegueWithIdentifier:@"search" sender:nil];
}

And the main problem arise here, can't navigate using below code:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  PackageListVC *pdvc = (PackageListVC *)[self.storyboard instantiateViewControllerWithIdentifier:@"PackageListVC"];

  pdvc.strServiceProviderId = [[[arrSearch objectAtIndex:indexPath.row] objectForKey:@"ServiceProviderId"] stringValue];
  pdvc.strCategoryId = [[[arrSearch objectAtIndex:indexPath.row] objectForKey:@"CategoryId"] stringValue];
  pdvc.strSubCategoryId = [[[arrSearch objectAtIndex:indexPath.row] objectForKey:@"SubCategoryId"] stringValue];
  pdvc.strTitle = [[arrSearch objectAtIndex:indexPath.row] objectForKey:@"CompanyName"];

  [self.navigationController pushViewController:pdvc animated:YES];
}
Anupam Das
  • 67
  • 10

1 Answers1

0

You do it in the prepareForSegue method.

where you declare svc (SearchVC *svc = segue.destinationViewController;) you can say something like:

 svc.variable = 1;
Niall Kiddle
  • 1,477
  • 1
  • 16
  • 35