ing*_*por 6 iphone xcode uinavigationbar uinavigationcontroller
当我点击屏幕时,我使导航栏(顶部栏)出现/消失,并且还位于背景图像的顶部.它有效,但有一个问题:我突然有两个导航栏!首先,一个带有一个名为"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
Run Code Online (Sandbox Code Playgroud)
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];
}
}
Run Code Online (Sandbox Code Playgroud)
通常,像您所描述的那样的重复导航栏是由两次推动同一视图控制器之类的原因引起的。您能否检查以确保仅将单个视图控制器推送到导航堆栈(通过断点或日志记录?)。winesDetailViewController 是否可能已经在导航堆栈上?您还可以尝试记录 的值self.navigationController.viewControllers以获取提示。
我也建议搬家
self.navigationController.navigationBar.translucent = YES;
Run Code Online (Sandbox Code Playgroud)
viewWillAppear 和
self.wantsFullScreenLayout = YES;
Run Code Online (Sandbox Code Playgroud)
到你的初始化程序(虽然我不认为这会解决你的问题)。
| 归档时间: |
|
| 查看次数: |
2832 次 |
| 最近记录: |