當我點擊屏幕時,導致我導航欄(頂部欄)出現/消失,並且也位於背景圖像的頂部。它的工作,但有一個問題:我突然有兩個導航欄!首先,有一個後退按鈕命名爲「後退」,當我按下「後退」時,它會彈出一個新的導航欄,並帶有名爲「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];
}
}
張貼圖片請 – Legolas