我有一个普通的UIPopoverController是这样制作的:

-(IBAction)btKBIs_click:(id)sender
{

if(kbiPopOver != NULL)
    [kbiPopOver dismissPopoverAnimated:YES];

KBIViewController *kbiViewController = [[KBIViewController alloc]initWithNibName:@"KBIViewController" bundle:nil CurrentUser:currentUser];
kbiViewController.currentStatus = FIRST;
kbiViewController.firstlist = [currentUser getDescriptions];
kbiViewController.mapViewController =self;


UINavigationController* kbiNavController = [[UINavigationController alloc] initWithRootViewController:kbiViewController];

kbiPopOver = [[UIPopoverController alloc] initWithContentViewController:kbiNavController];
kbiPopOver.delegate = self;

kbiViewController.kbiPopOver = kbiPopOver;

[kbiPopOver presentPopoverFromBarButtonItem:sender
                     permittedArrowDirections:UIPopoverArrowDirectionUp animated:true];

}


在类KBIViewController中,我正在调用:

    [self.kbiPopOver dismissPopoverAnimated:YES];
    [self.kbiPopOver.delegate popoverControllerDidDismissPopover:self.kbiPopOver];


要消除它,但它不起作用。为什么?

最佳答案

您是否在类接口中添加了<UIPopOverControllerDelegate>并实现了– popoverControllerDidDismissPopover:方法?在弹出窗口外点击时,只需在代码或delgate方法中显式调用dismissPopoverAnimated:。从您的代码中删除该[self.kbiPopOver.delegate popoverControllerDidDismissPopover:self.kbiPopOver];

关于ios - UIPopoverController无法关闭,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10796507/

10-09 16:29