我怎样才能移动到另一个的UIViewController programaticlly

问题描述:

我使用的是用故事板4.3.3的XCode我怎样才能移动到另一个的UIViewController programaticlly

我想搬到一个两UIViewControllers取决于一个if条件的结果。 有没有办法做到这一点,因为我尝试了一些代码,但它不工作,而不是显示错误。

为前:

[self performSegueWithIdentifier:@"You identifier" sender:self]; 

按住从您最初的视图控制器到一个目的地,一个在时间控制和阻力。每次选择您想要使用的segue的类型(除非初始控制器嵌入到UINavigationController中,否则push segue将不起作用)。然后点击每个赛格,打开属性检查器,并给每个唯一的名称。然后做类似

if (condition) { 
    [self performSegueWithIdentifier:@"Segue1" sender:self]; 
} 

else { 
    [self performSegueWithIdentifier:@"Segue2" sender:self]; 
} 
+0

谢谢我添加了UINavigationController,它适用于我 – user1434025 2012-07-17 12:33:44