如何使用 IOS 8 XCode 6 beta 从 Popover 中的按钮关闭 UIPopover
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25189246/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to dismiss UIPopover from a button in the Popover with IOS 8 XCode 6 beta
提问by user3919517
I managed to display popover using UIPopoverPresentationController
as the UIPopoverController
got deprecated in IOS 8, but now I want to dismiss the popover on tap of button from the popover.
我成功地显示酥料饼的使用UIPopoverPresentationController
作为UIPopoverController
得到了在IOS 8过时了,但现在我想解雇从酥料饼按钮的水龙头酥料饼。
How can it be dismissed?
怎么可能被驳回?
回答by Abhijit
Use presentingViewController property of the UIViewController to dismiss. Eg: To present
使用 UIViewController 的presentingViewController 属性关闭。例如:呈现
vc.modalPresentationStyle = UIModalPresentationPopover;
vc.preferredContentSize = aPreffferedSize;
UIPopoverPresentationController *popcontroller = vc.popoverPresentationController;
popcontroller.barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:view];
popcontroller.permittedArrowDirections = UIPopoverArrowDirectionAny;
popcontroller.delegate = self;
[self presentViewController:vc animated:YES completion:nil];
To dismiss programatically,
以编程方式关闭,
[[vc presentingViewController] dismissViewControllerAnimated:YES completion:NULL];
Hope this helps.
希望这可以帮助。
回答by MirekE
I am using
我在用
dismissViewControllerAnimated(true, completion: nil)
in the button's IBAction in similar scenario.
在类似场景中按钮的 IBAction 中。