OGeek|极客世界-中国程序员成长平台

标题: ios - 在 didSelectRowAtIndexPath 上关闭 ios 中的弹出框 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 12:00
标题: ios - 在 didSelectRowAtIndexPath 上关闭 ios 中的弹出框

我有一个弹出框,它在导航栏按钮上弹出,并且该弹出框包含一个表格 View 。 如何在tableview的didSelectRowAtIndexPath方法上关闭ios中的popover?



Best Answer-推荐答案


如果您的意思是 tableView 在该弹出框内,并且您的弹出框 Controller 是这样实例化的:

Objective-C

在包含的 Controller 中,将它放在它的顶部:

@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 类中你需要在 didSelectRowAtIndexPath 方法中调用这个方法:

[self dismissViewControllerAnimated:YES completion:nil];

关于ios - 在 didSelectRowAtIndexPath 上关闭 ios 中的弹出框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39305330/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4