[英]Dismiss UIPopOverPresentationcontroller
我有ViewControllerA类,从中提供了一个UIPopoverPresentationcontroller
,它可以显示B类的数据,效果很好。 当我在弹出菜单中选择一个值时,我想关闭它。 我的代码如下
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *getLang=[self.myArr objectAtIndex:indexPath.row];
if ([getLang isEqualToString:@"Ragul"]) {
getLang=@"Received";
}
else if ([getLang isEqualToString:@"Gokul"])
{
getLang=@"Denied";
}
ViewControllerA *viewCont=[[ViewControllerA alloc]init];
viewCont.delegate=self;
[self dismissViewControllerAnimated:YES completion:nil];
[viewCont anOptionalMethod:getLang];
}
anOptionalMethod是一个自定义委托方法,我调用它来显示具有从PopOver中选择的值的数据。
-(void)anOptionalMethod:(NSString *)langLocal
{
[self viewDidLoad];
self.popController.delegate = self;
[self.ContPop dismissViewControllerAnimated:YES completion:nil];
self.langShown=YES;
lblText.Text=MyValue;
[self.view addSubview:lblText]; // This calls viewDidLoad method
}
当我使用[Self.view addSubview:MyValue]
将结果添加到ViewControllerA
,将调用viewDidLoad
方法。 因此,这不应该发生。 我知道popOverPresentationController
充当父视图,所以我遇到了这个问题。 所以请帮我解决这个问题。 先感谢您..
要以编程方式关闭UIPopoverPresentationcontroller
,
[[vc presentingViewController] dismissViewControllerAnimated:YES completion:NULL];
希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.