2015-12-09 43 views
0

我恢復了我的項目,得到了以下storybard導航條只出現第1頁,其他不再出現

StoryBoard

而且在CollectionViewController我有以下的代碼,我的問題是,當我打電話其他頁面,導航欄自敗

<pre> - (void)viewDidLoad { 
    [super viewDidLoad]; 

    //navigation bar 
    UIImage *image = [UIImage imageNamed:@"home.png"]; 
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
    backButton.frame = CGRectMake(0, 0, 50, 50); 
    [backButton setImage:image forState:UIControlStateNormal]; 
    UIBarButtonItem *button2 = [[UIBarButtonItem alloc] initWithCustomView:backButton]; 
    self.navigationItem.leftBarButtonItem = button2; 
    self.title = @"Welcome User"; 

    marrImages=[[NSMutableArray alloc]init]; 

    mdictImageData=[[NSMutableDictionary alloc]initWithObjectsAndKeys:@"circlshadow_parking.png",@"imageFile",@"Parking",@"Info",nil]; 
    [marrImages addObject:mdictImageData]; 

} 

-(void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 
    [[self navigationController] setNavigationBarHidden:NO animated:YES]; 
} 


- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSUInteger lastIndex = [indexPath indexAtPosition:[indexPath length] - 1]; 
    if(lastIndex == 0) 
    { 
     UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
     UIViewController *myVC = (UIViewController *)[storyboard instantiateViewControllerWithIdentifier:@"ParkingMenu"]; 
     myVC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
     [self presentModalViewController:myVC animated:YES]; 
    } 
}<code> 
+0

我們展示你的故事板。向我們展示屏幕截圖。告訴我們你如何從一個頁面移動到另一個頁面。告訴我們你是如何「回家」的。 – jcaron

+0

我的故事板是http://s30.postimg.org/srmobz201/Captura_de_Tela_2015_12_07_s_16_18_05.png,我打電話給這樣的頁面:UIStoryboard * mainStoryboard = [UIStoryboard storyboardWithName:@「Main」bundle:nil]; UIViewController * vc = [mainStoryboard instantiateViewControllerWithIdentifier:@「ParkingMenu」]; [self presentViewController:vc animated:YES completion:NULL];因爲我有一個集合視圖控制器 – HideCode

+0

請編輯您的問題以添加詳細信息。 – jcaron

回答

0

根據您的故事板的設置,你真的應該使用塞格斯而不是手動實例化和呈現視圖控制器。

根據故事板屏幕截圖中模糊的圖標,看起來您已成功將它們設置爲「顯示」搜索結果。你的問題在別處存在的可能性很小,但這肯定會使你轉向更「標準」和最佳實踐的做事方式。

要解決此問題,請在集合視圖控制器和泊車菜單視圖控制器之間的連線上設置輪巡標識符。假設segue被識別爲「ParkingMenuSegue」。然後,當你需要呈現,使用:

的Objective-C:

[self performSegueWithIdentifier:@"ParkingMenuSegue" sender:sender]; 

斯威夫特:

performSegueWithIdentifier("ParkingMenuSegue", sender: nil)