IOS - Create a Popover View with StoryBoard

Hi, Now I am trying to create a Pop-OverView using an Xcode storyboard. First i

rootViewController, UIViewController, and UITableViewController 

I want the UIView to act like a page flip, and the UITableView display popOver in the navigation control.

For UITableView, I want to do Pop-Over in the NavigationBar controller. The problem is that when I touch the Navigation element to show the UITableViewController, it displays correctly, but when I try to close the Pop-Over View, it will not close. And then the navigation element does not work. It shows multiple instances of popOverView when I touch it several times.

That doesn't seem to make sense to me. Can someone help me or tell me where to find documentation / tutorials on this?

UPDATE:

For UIPopOverController, it seems to work fine, but it still listens to me when I touch the navigation item several times. It will show several instances of PopOver. How can I handle it, so it will only display one instance?

+3
source share
1 answer

I had the same problem and basically found a solution here . Basically, you change the action of a button every time it is pressed to display or reject a popover. Here is the code I hit:

 @interface FilterTableViewController : UITableViewController { UIPopoverController *editPopover; id saveEditSender; id saveEditTarget; SEL saveEditAction; } -(void)prepareForSegue:(UIStoryboardPopoverSegue *)segue sender:(id)sender{ if([[segue identifier] isEqualToString:@"EditFilterSegue"]){ // Save the edit button info so we can restore it saveEditAction = [sender action]; saveEditTarget = [sender target]; saveEditSender = sender; // Change the edit button target to us, and its action to dismiss the popover [sender setAction:@selector(dismissPopover:)]; [sender setTarget:self]; // Save the popover controller and set ourselves as the its delegate so we can // restore the button action when this popover is dismissed (this happens when the popover // is dismissed by tapping outside the view, not by tapping the edit button again) editPopover = [(UIStoryboardPopoverSegue *)segue popoverController]; editPopover.delegate = (id <UIPopoverControllerDelegate>)self; } } -(void)dismissPopover:(id)sender { // Restore the buttons actions before we dismiss the popover [saveEditSender setAction:saveEditAction]; [saveEditSender setTarget:saveEditTarget]; [editPopover dismissPopoverAnimated:YES]; } -(BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController { // A tap occurred outside of the popover. // Restore the button actions before its dismissed. [saveEditSender setAction:saveEditAction]; [saveEditSender setTarget:saveEditTarget]; return YES; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; // Before we navigate away from this view (the back button was pressed) // remove the edit popover (if it exists). [self dismissPopover:saveEditSender]; } 
+3
source

Source: https://habr.com/ru/post/1396088/


All Articles