【问题标题】:dismiss popover in ios on didSelectRowAtIndexPath在 didSelectRowAtIndexPath 上关闭 ios 中的弹出框
【发布时间】:2016-09-03 09:24:02
【问题描述】:

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

【问题讨论】:

标签: ios uinavigationbar uipopovercontroller


【解决方案1】:

如果您的意思是 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 类中你需要在 didSelectRowAtIndexPath 方法中调用这个方法:

[self dismissViewControllerAnimated:YES completion:nil];

【讨论】:

  • pedrouan ioscreator.com/tutorials/display-popovers-on-the-ipad 我正在使用类似这样的东西
  • 我知道@rva,我的解决方案适合它。不要忘记应用属性(非原子,强) UIPopoverController *popOver;
【解决方案2】:

你可以使用

Obj-c

[popoverController dismissPopoverAnimated:YES];

斯威夫特

popoverController.dismissPopoverAnimated(true)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-04
    • 1970-01-01
    • 2014-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多