`present` 和 `push` 的区别 ViewController

Difference between `present` & `push` ViewController

dismissViewController 方法无法获取以前的 viewcontoller

[self.navigationController dismissViewControllerAnimated:YES completion:nil];

popViewController 工作并转到上一个 viewcontroller

[self.navigationController popViewControllerAnimated:YES];

我想像下面这样传递数据,请帮助 me.but 正如我所描述的 dismissViewController 方法不起作用。

 [self.navigationController dismissViewControllerAnimated:YES completion:^{
            HomeVC *loading;
            loading.IdNameLabel.text=display;
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Code" message:display delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alert show];
 }];

提前致谢。

更新

-(void)viewWillAppear:(BOOL)animated{
    self.IdNameLabel.text=self.GetscanResult;
}

此方法包含在 HomeVC.when 关闭 navcontroller 它显示 HomeVC。

dismiss后可以调用上面的方法吗viewcontroller?

解决方案

当我处于初学者水平时,这是一个非常愚蠢的问题。 这是关于它的规范。 这将取决于您 Present || 的方法Push viewController.

当存在视图控制器时,委托方法将与协议委托方法一起工作。

返回时需要使用的方法取决于显示视图控制器的方式。

两种常见方法中的第一种是使用导航视图控制器将视图控制器推送和弹出堆栈。

另一种常见的方式是以模态方式呈现和关闭视图控制器。

例如,您不能以模态方式呈现视图控制器,并期望能够将其从导航控制器中弹出,反之亦然。