rag*_* ml 1 iphone objective-c uipopovercontroller ios
我有一个类ViewControllerA,我可以UIPopoverPresentationcontroller从中显示B类显示的数据,工作正常.当我在pop中选择一个值时,我想解雇它.我的代码如下
- (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];
}
Run Code Online (Sandbox Code Playgroud)
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
}
Run Code Online (Sandbox Code Playgroud)
当我将结果添加到ViewControllerA与[Self.view addSubview:MyValue]该viewDidLoad方法被调用.所以这不应该发生.我知道这popOverPresentationController充当了父视图,因此我遇到了这个问题.所以请帮我解决这个问题.先感谢您..
要以UIPopoverPresentationcontroller编程方式解雇,
[[vc presentingViewController] dismissViewControllerAnimated:YES completion:NULL];
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.
| 归档时间: |
|
| 查看次数: |
4303 次 |
| 最近记录: |