FrankTan
FrankTan

Reputation: 1686

UIPopoverController does not close

I have a normal UIPopoverController which is made in this way:

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

}

Inside the class KBIViewController I'm calling:

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

To dismiss it but it does not work. Why?

Upvotes: 1

Views: 753

Answers (1)

ott--
ott--

Reputation: 5722

Did you add the <UIPopOverControllerDelegate> in your class interface and did you implement the – popoverControllerDidDismissPopover: method? Just call the dismissPopoverAnimated: explicitly in your code or in the delgate method, when you tap outside the popover. Remove that [self.kbiPopOver.delegate popoverControllerDidDismissPopover:self.kbiPopOver]; from your code.

Upvotes: 1

Related Questions