Tôi đã tạo thanh điều hướng (thanh trên cùng) xuất hiện/biến mất khi tôi nhấn vào màn hình và cũng nằm ở trên cùng của hình nền. Nó hoạt động, nhưng với một vấn đề: tôi đột nhiên có hai thanh điều hướng! Đầu tiên, một với một nút quay lại có tên "Back", và khi tôi bấm "Back" nó sẽ bật lên một thanh điều hướng mới với một nút quay lại có tên "Vinene", đó là tiêu đề của TableView nó dẫn trở lại. Đó là điều tôi muốn giữ. Tôi nghĩ rằng vấn đề là một nơi nào đó trong DetailViewController.m hoặc trong didselectrowatindexpath trong MasterViewController.m. Hy vọng ai đó có thể nhìn thấy vấn đề!Thanh điều hướng hai chiều không mong muốn
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];
}
}
bài đăng hình ảnh vui lòng – Legolas