ios - 关闭 ios 中 didSelectRowAtIndexPath 上的弹出窗口

标签 ios uinavigationbar uipopovercontroller

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

最佳答案

如果您的意思是 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 - 关闭 ios 中 didSelectRowAtIndexPath 上的弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39305330/

相关文章:

ios - 是否可以刷新 UITableViewCell 中的一个 View

iOS7 JavaScriptCore框架兼容性

iphone - 在 iPhone 窗口上添加一个 View ,甚至在 UINavigationBar 上方

ios - UIActivityViewController 需要很长时间才能呈现

ios - 调整 UIPopoverController 的大小以适应 UITableController

ios - 如何将警报弹出 View 与自定义警报弹出 View 切换?

javascript - WkWebView 无法打开输入字段的键盘

ios - 如何摆脱导航栏和手机顶部之间的空间

css - 居中对齐导航项

ios - iPad SplitViewController 以编程方式显示 Popover