2013-10-24 20 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