SEGUE调用但没有被解雇

问题描述:

我用故事板的第一次和我有SEGUE一个问题,我的故事板是这样的:SEGUE调用但没有被解雇

          __ ViewController 
             /
         __ TabBarController 
        /     \__ ViewController 
        /
-> TableViewController 
        \ 
         \__ NavigationController ___ ViewController 

我创建2 SEGUE,一个TabBarController,一个用于NavigationController使用标识符“AddServer”(用于NavigationController)和“GoMainBoard”(用于TabBarController)。从我TableViewController使用自定义的测试,我火TabBarController或NavigationController与此代码

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
     [_tbvDownloads deselectRowAtIndexPath:indexPath animated:YES]; 

     if (indexPath.row == [tableView numberOfRowsInSection:0]-1) { 
      [self performSegueWithIdentifier:@"AddServer" sender:self]; 
     } else { 
      ... 
       [self performSegueWithIdentifier:@"GoMainBoard" sender:self]; 
      ... 
     } 
    } 

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
    if ([segue.identifier isEqualToString:@"AddServer"]) 
    { 
     UINavigationController *navigationController = segue.destinationViewController; 
     ... 
    } 
    if ([segue.identifier isEqualToString:@"GoMainBoard"]) 
    { 
     UITabBarController *tabBar = (UITabBarController *)segue.destinationViewController; 
    } 
} 
  • (无效)prepareForSegue叫,但我的TabBarController不开除,谁能给我解释一下,我犯了一个错误?谢谢

显然,push segue只能在导航控制器内工作。在其他情况下,您将不得不使用'模态'类型。希望能回答你的问题:)

另请参阅:segue does not work in simple segue test