PDA

View Full Version : Closing a popover with a button (within another .xib file)




BarryK88
May 19, 2011, 08:45 AM
I've got a popover within my view. Within this popover there is content from another xib file (Infoscreen.xib). How can I dismiss the popover with a button which is inside another .xib file? Here's a snippit of my code:

-(IBAction)infoDruk: (id)sender {

if([popover isPopoverVisible]) {
[popover dismissPopoverAnimated:YES];

}
else {

Infoscreen *choser = [[Infoscreen alloc] init];
popover = [[UIPopoverController alloc]
initWithContentViewController:choser];
[choser release];
popover.delegate = self;
popover.popoverContentSize = CGSizeMake(230, 563);
[popover presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
}

Help is greatly appreciated!



robbieduncan
May 19, 2011, 08:59 AM
There doesn't seem to be a "popoverController" property in UIViewController which is a shame. So create on in Infoscreen and set it in the method you have posted. This will give methods in your Infoscreen instance access to the UIPopoverController instance.