Closing a popover with a button (within another .xib file)
-
15-11-2019 - |
Question
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!
Solution
Your another xib should inform (give a call back) to your pop over that such button has been pressed. This concept is called delegates. Thus, you can dismiss the pop over in this call back method.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow