How to pass parameters to a popover view controller inside a navigation controller

后端 未结 2 1092
清酒与你
清酒与你 2021-01-13 16:48

I have an iPad app with splitview and a right bar button in the navigation bar of the detailviewcontroller.

This button calls a popover constituted of a navigation c

2条回答
  •  深忆病人
    2021-01-13 17:21

    All the credit belongs to @Michael Kernahan, but as long as he don't post it as an answer I'll write it as a follow up for people looking for the same answer.

    In my case the problem was that I am assigning the destination controller which is the navigation controller

    popoverFirstTVC = segue.destinationViewController; 
    

    what I should do is to access the topViewController of that navigation controller.

    -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        if([[segue identifier] isEqualToString:@"popoverButtonSegue"]){
            MyPopoverFirstTableViewController *popoverFirstTVC = (MyPopoverFirstTableViewController *)((UINavigationController *) segue.destinationViewController).topViewController;
    
            popoverFirstTVC.property1 = aProperty1;
            popoverFirstTVC.property2 = aProperty2;
    }
    

提交回复
热议问题