Ios 解除UIPopOverPresentationcontroller

Ios 解除UIPopOverPresentationcontroller,ios,objective-c,iphone,uipopovercontroller,Ios,Objective C,Iphone,Uipopovercontroller,我有一个ViewControllerA类,从中我展示了一个UIPopoverPresentationcontroller,它显示B类的数据,工作正常。当我在弹出窗口中选择一个值时,我想将其忽略。我的代码如下 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSString *getLang=[self.myArr objectAtIndex:ind

我有一个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];

希望这有帮助。

要以编程方式关闭
UIPopoverPresentationcontroller

  [[vc presentingViewController] dismissViewControllerAnimated:YES completion:NULL];

希望这有帮助。

在关闭
视图控制器之前,请尝试调用
一个可选方法委托
show
anOptionalMethod
method以清除如何将
MyValue
传递给
ViewControllerA
。-(void)anOptionalMethod:(NSString*)langLocal{[self.popOverController dismissViewControllerAnimated:YES completion:nil];self.langshow=YES;[self];}。很抱歉,这是错误的。。按如下方式查找代码-(void)anOptionalMethod:(NSString*)langLocal{[self-viewDidLoad];self.popController.delegate=self;[self.ContPop dismissViewControllerAnimated:YES完成:nil];self.langShowed=YES;lblText.Text=MyValue;[self.view addSubview:lblText];//这调用viewDidLoad方法}[self.view addSubview:lblText]调用viewDidLoad方法尝试调用
anOptionalMethod委托
,然后关闭
view控制器
。&show
anOptionalMethod
方法以清除如何将
MyValue
传递给
ViewControllerA
。-(void)anOptionalMethod:(NSString*)langLocal{[self.popOverController dismissViewControllerAnimated:YES完成:nil];self.langShowed=YES;[self];}很抱歉,这是错误的。按如下方式查找代码-(void)anOptionalMethod:(NSString*)langLocal{[self viewDidLoad];self.popController.delegate=self;[self.ContPop dismissViewControllerAnimated:YES完成:nil];self.langShowed=YES;lblText.Text=MyValue;[self.view addSubview:lblText];//这将调用viewDidLoad方法}[self.view addSubview:lblText]调用viewDidLoad方法可能有助于注意本例中的
vc
指的是弹出窗口中显示的视图控制器。可能有助于注意本例中的
vc
指的是弹出窗口中显示的视图控制器。