0

The issue is normally when user have open a popover view, when he press outside the view, the popover view will dismiss. So it would not have multiple popover view display at the same time.

Now the tricky problem is, if the user press on 2 buttons that will open popover view popover at the same time, the action will not dismiss either one of the popover view. I guess maybe the animation have delay the "actual popover view have actually pop over yet" before another does. Now 2 pop over will display together, which i do not wish to happen. I need to force only 1 pop over at a time.

Sorry for my question may confuse you.

user1151874
  • 269
  • 3
  • 5
  • 15

1 Answers1

0

You need to remember that you have handled a hit event on the first button, and then ignore the second button press. All button press hit events will be dispatched on the main thread, so you can never get two press events simultaneously.

e.g

-(IBAction)buttonTouched:(id)sender 
{
    if(self.presentingPopover)
    {
        return;
    } 
    self.presentingPopover = YES;

    // present the popover, set ourselves up as delegate
}


// From UIPopoverControllerDelegate
-(void)popoverControllDidDismissPopover:(UIPopoverController*)popover
{
    self.presentingPopover = NO;
}
Airsource Ltd
  • 32,379
  • 13
  • 71
  • 75
  • How to ignore the second button? The fact is when i press together, it does send 2 touch event to the action. – user1151874 Jan 15 '15 at 11:15
  • It sends two touch events, but they will be processed sequentially, not simultaneously. As for how to ignore it, what does the code currently look like? You must have a view controller somewhere, so just record there that you have started opening a popover, and ignore any event that tries to open a second popover until the first one has closed. – Airsource Ltd Jan 15 '15 at 11:21
  • Ok, i understand your approach, but where should i implement this funtion? Because every component with the popover feature also have it own instance, then how do "self.presentingPopover" work for another instance? Thanks – user1151874 Jan 16 '15 at 02:16
  • opps, i have misunderstood your approach. You mean do it at the view controller there.It can works, Thanks. But Is that anyway i can do it at the popOverController there? So that i no need to do at every view controller. – user1151874 Jan 16 '15 at 03:59