从UIButton呈现的UIPopoverController不隐藏?

时间:2011-01-25 20:44:20

标签: iphone objective-c ipad

我有一个UIPopoverController,它是从我的UIViewController上的按钮呈现的,但当我点击视图的任何不是popover的部分时它没有隐藏?

显示弹出窗口的按钮是动态创建的,您将看到以下代码中引用的按钮:

-(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];
}

2 个答案:

答案 0 :(得分:1)

我意识到这不太可能,但您的ModifierListPopoverViewController类是否将其modalInPopover属性设置为YES? (默认值为NO,它可以为您提供所需的行为。)

答案 1 :(得分:0)

似乎有些观点可以解决触摸事件。