rva
rva

Reputation: 57

dismiss popover in ios on didSelectRowAtIndexPath

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?

Upvotes: 2

Views: 232

Answers (2)

pedrouan
pedrouan

Reputation: 12910

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

Upvotes: 2

Marco Santarossa
Marco Santarossa

Reputation: 4066

You can use

Obj-c

[popoverController dismissPopoverAnimated:YES];

Swift

popoverController.dismissPopoverAnimated(true)

Upvotes: 1

Related Questions