rva rva - 3 months ago 19
iOS Question

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 I Dismiss popover in ios on didSelectRowAtIndexPath method of tableview

Answer

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