2
votes

I am having one popover which pop up on navigationbar button and that pop up contains a tableview. How can dismiss popover in ios on didSelectRowAtIndexPath method of tableview?

2
Can you show the code where you have popover the Popup?Nirav D

2 Answers

2
votes

If you meant that a tableView is inside that popover and your popover controller is instantiated like this:

Objective-C

In the containing controller, place this on the top of it:

@property (nonatomic,strong) UIPopoverController *popOver;

//this is the content of the popover
MyTableVC *tableVC = [self.storyboard instantiateViewControllerWithIdentifier:@"myTableView"];
//this is the navigation controller of your tableViewController
UINavigationController *popNav = [[UINavigationController alloc] initWithRootViewController:tableVC];
//this is you popover
self.popOver =[[UIPopoverController alloc] initWithContentViewController:popNav];

then you have to dismiss it inside that viewController, which you have created the popover from, in this case it's popNav for example.

So in you MyTableVC class you need to call this method in the didSelectRowAtIndexPath method:

[self dismissViewControllerAnimated:YES completion:nil];
1
votes

You can use

Obj-c

[popoverController dismissPopoverAnimated:YES];

Swift

popoverController.dismissPopoverAnimated(true)