Dismissing iPad UIPopoverController when BarButtonItem is pushed while it's open

后端 未结 7 1183
闹比i
闹比i 2020-12-14 11:36

Using a split view on the iPad, I have the following code:

- (void) splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController         


        
7条回答
  •  南方客
    南方客 (楼主)
    2020-12-14 12:06

    If you are using the default UISplitViewController setup, then the navigation bar button that is created displays a popover of your RootViewController.

    If you want to make sure you don't have multiple pop-ups on at once, you can simply dismiss pop-ups whenever your RootViewController will appear. Here's code I used to solve this problem:

    - (void) viewWillAppear:(BOOL)animated {
      if ([self.popover isPopOverVisible]) {
        [self.popover dismissPopoverAnimated:YES];
      }
      [super viewWillAppear:YES];
    }
    

提交回复
热议问题