2013-10-24 23 views
2

我想要在storyboard与tabBar和外部xib之间传递数据。 我试图使用prepareforsegue,但该方法没有调用,或者如果我定义了一个segue,但没有认识到这一点。在storyboard与tabBar和外部xib之间传递数据

我的代码是:

UIStoryboard *storyborad = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
     UIViewController *view = [storyborad instantiateViewControllerWithIdentifier:@"<identifier>"]; 
     [self.navigationController setNavigationBarHidden:YES]; 
     [self.navigationController pushViewController:view animated:YES]; 
    // [self performSegueWithIdentifier:@"try" sender:self]; // tried to use performSegueWithIdentifier but this recognize identifier 

和prepareforsegue方法代码:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 

BIDViewController *viewControllerView = segue.destinationViewController; 
viewControllerView.isViewPushed=1; 
NSLog(@"prepareForSegue"); 
+0

您是否在xib中设置了标识符? – Alex

+0

故事板中没有 – user2915374

+0

你有一个故事板,你想推到一个笔尖文件,不是吗?所以你可以使用[self performSegueWithIdentifier @“try”sender:self],但是你需要在目标nib中设置该标识符(“try”)。在nib中设置标识符后,prepareSegue函数将被调用。 – Alex

回答

0

取而代之的是:

UIStoryboard *storyborad = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
UIViewController *view = [storyborad instantiateViewControllerWithIdentifier:@"<identifier>"]; 
[self.navigationController setNavigationBarHidden:YES]; 
[self.navigationController pushViewController:view animated:YES]; 

试试这个:

UIStoryboard *storyborad = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
BIDViewController *view = [storyborad instantiateViewControllerWithIdentifier:@"myIdentifier"]; 
view.isViewPushed = 1; 
[self.navigationController setNavigationBarHidden:YES]; 
[self.navigationController pushViewController:view animated:YES]; 
+0

视图不连接到类没有SEGUE有这个属性 – user2915374

+0

对于双后,抱歉,但问题仍然存在 – user2915374

+0

你可以检查是否视图从BIDViewController是零? – Alex