Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 不需要的双导航栏_Iphone_Xcode_Uinavigationcontroller_Uinavigationbar - Fatal编程技术网

Iphone 不需要的双导航栏

Iphone 不需要的双导航栏,iphone,xcode,uinavigationcontroller,uinavigationbar,Iphone,Xcode,Uinavigationcontroller,Uinavigationbar,当我点击屏幕时,我使导航栏(顶部栏)出现/消失,并且也位于背景图像的顶部。它工作了,但有一个问题:我突然有两个导航栏!首先,它有一个名为“back”的后退按钮,当我按下“back”时,它会弹出一个新的导航栏,其中有一个名为“Vinne”的后退按钮,这是它返回到的TableView的标题。这就是我想要保留的。我认为问题出在DetailViewController.m或MasterViewController.m中的didselectrowatindexpath中。希望有人能看到这个问题 Detai

当我点击屏幕时,我使导航栏(顶部栏)出现/消失,并且也位于背景图像的顶部。它工作了,但有一个问题:我突然有两个导航栏!首先,它有一个名为“back”的后退按钮,当我按下“back”时,它会弹出一个新的导航栏,其中有一个名为“Vinne”的后退按钮,这是它返回到的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
- (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];
    }
}
MasterViewController.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
- (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];
    }
}

通常,如您所述的重复出现的导航栏是由两次按下同一视图控制器之类的操作引起的。是否可以检查以确保只将单个视图控制器推送到导航堆栈上(通过断点或日志?)。winesDetailViewController是否可能已在导航堆栈上?您还可以尝试记录
self.navigationController.viewControllers
的值以获取提示

我还建议搬家

self.navigationController.navigationBar.translucent = YES;
查看将出现和

self.wantsFullScreenLayout = YES;

给你的初始值设定者(虽然我不认为这能解决你的问题)。

我想这就是问题所在,听起来很合乎逻辑。我尝试将som数据从tableview传递到detail view,但这很棘手,因为我是新手。我已经建立了一个故事板连接,从原型单元到故事板中的细节视图,以及我在问题中发布的didselectrowatindexpath代码。到目前为止,除了双栏外,它工作得很好。如果你用这种方式使用故事板,你可能想使用类似于这个问题所建议的东西;不要推送自己的详细视图控制器。