Slee
Slee

Reputation: 28248

UIPopoverController presented from a UIButton does not hide?

I have a UIPopoverController that is presented from a button on my UIViewController but when I tap on any part of the view that is not the popover it is not hiding?

The buttons that present this popover are created dynamically, you'll see that referenced in the code below:

-(IBAction)showModifiers:(id)sender{

    [self.popoverController dismissPopoverAnimated:YES];

    UIView *theSuperview = self.view; 
    CGPoint touchPointInSuperview = [sender locationInView:theSuperview];
    UIView *touchedView = [theSuperview hitTest:touchPointInSuperview withEvent:nil];

    currentPopoverTag = [touchedView tag];
    NSLog(@"Show Modifiers %i %i", [touchedView tag], currentPopoverTag);

    RepZioCoreDataAppDelegate *appDelegate  = [[UIApplication sharedApplication] delegate];
    if (appDelegate.popoverController)
        [appDelegate.popoverController dismissPopoverAnimated:YES];

    self.modifierListPopoverViewController = nil;   
    ModifierListCollection *collection = [self.modifierLists objectAtIndex:[touchedView tag]-100];
    ModifierList *modifierList = [self getModifierList:collection.ModifierListID];
    self.modifierListPopoverViewController =
    [[[ModifierListPopoverViewController alloc] initWithModifierList:modifierList withManufacturerID: self.manufacturerID] autorelease];
    self.modifierListPopoverViewController.delegate = self;

    self.popoverController = [[[UIPopoverController alloc] initWithContentViewController:modifierListPopoverViewController] autorelease];
    [self.popoverController presentPopoverFromBarButtonItem:sender  permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}

Upvotes: 0

Views: 986

Answers (2)

Bryan Irace
Bryan Irace

Reputation: 1875

I realize it's unlikely, but does your ModifierListPopoverViewController class set its modalInPopover property to YES? (the default is NO, which should give you the behavior you're looking for).

Upvotes: 1

Max
Max

Reputation: 16719

It seems that some view tackles the touch event.

Upvotes: 0

Related Questions