我有一个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充当父视图,所以我遇到了这个问题。所以请帮我解决这个问题。提前ThankYou ..
发布于 2016-06-14 13:25:54
为了在编程上取消UIPopoverPresentationcontroller,
[[vc presentingViewController] dismissViewControllerAnimated:YES completion:NULL];希望这能有所帮助。
https://stackoverflow.com/questions/37802678
复制相似问题