multiple views navigation in UIPopovercontroller

2019-08-17 18:40发布

i have a button in the main view ..when the her tap that button it shoes the popoverview ,inside the popover i have a uiviewcontrolle,when the user tap the tableviewcell inside the popover it navigate to next page,,then the user tap any button of the next page ,,,it navigate to another view,all are inside popover..everything works fine..but here in my last view...i need to go to main page,,but i can see the main page inside the popover,i want to dismiss that popover and go tot main page,i tried many solutions nothing work for me,,this is my secod question regarding this issue...plz hale me to do this..the link of the first question isfirst question there is my code

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-08-17 18:43

Add a notification in main view's viewDidLoad

[[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(dismissThePopover:) 
                                             name:@"dismissThePopover" 
                                           object:nil];

write function in Main view

-(void)dismissThePopover:(id)sender
{
     if ([popoverController isPopoverVisible]) {
            [popoverController dismissPopoverAnimated:YES];
        }
}

and finally post the notification from where u have to dismiss the popover controller, like

-(IBAction)cancelButtonPressed:(id)sender
{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"dismissThePopover" object:nil];
}
查看更多
登录 后发表回答