在 didSelectRowAtIndexPath 上关闭 ios 中的弹出窗口
dismiss popover in ios on didSelectRowAtIndexPath
我有一个在导航栏按钮上弹出的弹出窗口,该弹出窗口包含一个表格视图。
如何在 ios 中关闭 popover on didSelectRowAtIndexPath
tableview 方法?
您可以使用
Obj-c
[popoverController dismissPopoverAnimated:YES];
Swift
popoverController.dismissPopoverAnimated(true)
如果您的意思是 tableView 位于该弹出框内并且您的弹出框控制器是这样实例化的:
Objective-C
在包含控制器中,将它放在它的顶部:
@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];
然后你必须在你从中创建弹出窗口的 viewController 中关闭它,例如在本例中它是 popNav。
所以在你的MyTableVC中class你需要在didSelectRowAtIndexPath方法中调用这个方法:
[self dismissViewControllerAnimated:YES completion:nil];
我有一个在导航栏按钮上弹出的弹出窗口,该弹出窗口包含一个表格视图。
如何在 ios 中关闭 popover on didSelectRowAtIndexPath
tableview 方法?
您可以使用
Obj-c
[popoverController dismissPopoverAnimated:YES];
Swift
popoverController.dismissPopoverAnimated(true)
如果您的意思是 tableView 位于该弹出框内并且您的弹出框控制器是这样实例化的:
Objective-C
在包含控制器中,将它放在它的顶部:
@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];
然后你必须在你从中创建弹出窗口的 viewController 中关闭它,例如在本例中它是 popNav。
所以在你的MyTableVC中class你需要在didSelectRowAtIndexPath方法中调用这个方法:
[self dismissViewControllerAnimated:YES completion:nil];