10

我不知道为什么dismissViewControllerAnimated:completion:。我只是想做。

我从一个

[self performSegueWithIdentifier:@"my_segue" sender:self];

但是我称之为解雇比什么都没有发生。我可以创建另一个 segue,但它会创建一个新的视图控制器。

我的问题是:如何解雇performSegueWithIdentifier:sender:

4

5 回答 5

31

您在 viewController 中是否有一个正在调用的导航栏:

[self performSegueWithIdentifier:@"my_segue" sender:self];

如果是这样,您将需要使用:

[self.navigationController popViewControllerAnimated:YES];

将视图从堆栈中弹出。有一个 segue 调用,但框架似乎调用:

presentViewController:animated:completion:

或者:

pushViewController:animated:

作为适当的。

射线

于 2013-04-03T18:28:30.230 回答
2

你可以打电话

[self dismissViewControllerAnimated:YES completion:nil];

来自视图控制器,因为视图控制器是由 segue 推送的。

于 2016-05-16T21:46:33.423 回答
0

performSegueWithIdentifier:sender:本身并没有被解雇,这只是被调用以启动命名segue的方法。segue中发生的事情更有趣。

您应该调用 是对的,dismissViewControllerAnimated:completion:它应该由呈现视图控制器调用,该控制器之前使用. 有关详细信息,请参阅UIViewcontroller 文档presentViewController:animated:completion:

于 2012-04-23T06:41:54.973 回答
0

[my_segue_view_controller dismissModalViewControllerAnimated: YES]?

(不确定,但它在我的实践中有效)

于 2012-04-23T06:02:15.047 回答
0

将以下代码用于Swift 4版本

  self.navigationController?.popViewController(animated: true)
于 2019-02-23T03:35:25.060 回答