2012-06-26 14 views
5

画面をタップするとナビゲーションバー(トップバー)が表示/非表示になり、背景画像の上にも表示されます。それはうまくいったが、1つの問題があった。私は突然2つのナビゲーションバーを手に入れた!最初に、 "Back"という名前の戻るボタンが付いたボタンと、 "Back"を押すと、新しいナビゲーションバーが "Vinene"という名前の戻るボタンとともにポップアップします。これは、元のTableViewのタイトルです。それは私が保持したいものです。私は問題がDetailViewController.mのどこか、またはMasterViewController.mのdidselectrowatindexpathにあると思います。誰かが問題を見ることができることを願っています!不要なダブルナビゲーションバー

DetailViewController.m:

@interface WinesDetailViewController() 

@end 

@implementation WinesDetailViewController 

@synthesize wineDictionary; 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
if (self) { 
    // Custom initialization 
} 
return self; 
} 

- (void)viewDidAppear:(BOOL)animated 
{ 
[super viewDidAppear:animated]; 

} 

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
// Do any additional setup after loading the view. 

self.navigationController.navigationBar.translucent = YES; 
         self.wantsFullScreenLayout = YES; 

UITapGestureRecognizer *tap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideShowNavigation)] autorelease]; 
                             tap.numberOfTapsRequired = 1; 
                           [self.view addGestureRecognizer:tap]; 
} 

- (void) hideShowNavigation 
{ 
[self.navigationController setNavigationBarHidden:!self.navigationController.navigationBarHidden]; 
} 

- (void)viewDidUnload 
{ 
[super viewDidUnload]; 
// Release any retained subviews of the main view. 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

- (BOOL)hidesBottomBarWhenPushed{ 
return TRUE; 
} 


@end 

MasterViewController.m:

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

    NSDictionary *dictionary = [wine libraryItemAtIndex:indexPath.row]; 

    if (winesDetailViewController == nil) { 
     // Init the wine detail view 
     winesDetailViewController = [[WinesDetailViewController alloc] init]; 
    } 
    // Here you pass the dictionary 
    winesDetailViewController.wineDictionary = dictionary; 

    [self.navigationController pushViewController:winesDetailViewController animated:YES]; 
    } 
} 
+0

投稿画像 – Legolas

答えて

3

通常、あなたが記述のような定期的なナビゲーションバーが二度同じビューコントローラをプッシュするような何かによって引き起こされます。あなたは、(ブレークポイントやロギングを介して)ナビゲーションスタックに1つのView Controllerを押し込むだけであることを確認できますか? winesDetailViewControllerが既にナビゲーションスタックにある可能性はありますか?ヒントの値をself.navigationController.viewControllersに記録することもできます。

私も(私はこれがあなたの問題を解決するとは思わないが)あなたの初期化子にviewWillAppearと

self.wantsFullScreenLayout = YES; 

self.navigationController.navigationBar.translucent = YES; 

を移動することをお勧め。

+0

私はその問題だと思います。私はテーブルビューから詳細ビューにsomデータを渡そうとしますが、これは初めてのため難しいです。私は、プロトタイプのセルからストーリーボードの詳細ビュー、そして私の質問に投稿したdidselectrowatindexexpathコードにストーリーボード接続を行いました。それは二重バーを除いてこれまでのところうまく動作します。 – ingenspor

+0

このようにストーリーボードを使用している場合は、この質問のようなものを使用することをお勧めします。自分の詳細ビューコントローラをプッシュしないでください。 http://stackoverflow.com/questions/8130600/use-didselectrowatindexpath-or-prepareforsegue-method-for-uitableview –