UIStoryboard instantiateViewControllerWithIdentifier被调用两次

时间:2014-04-21 01:16:56

标签: ios objective-c uistoryboard

我有这段代码,每次我使用它时,目标视图的viewDidLoad都会被调用两次。

为什么会这样?

Destination *myDestination = [self.storyboard instantiateViewControllerWithIdentifier:@"destination "];
MyCustomSegue *segue = [[MyCustomSegue alloc] initWithIdentifier:@"CustomSegue" source:self  destination : myDestination];
[segue perform];

1 个答案:

答案 0 :(得分:1)

我认为您可以通过调用方法presentViewController: animated: completion:;来实现此目的 e.g

Destination *myDestination = [self.storyboard instantiateViewControllerWithIdentifier:@"destination "];
[self presentViewController:myDestination animated:YES completion:nil];

我希望这会帮助你。