-1

我在 rootview 控制器上创建了导航栏

- (void)viewWillAppear:(BOOL)animated
{
    ///set hud
    [UIApplication sharedApplication].networkActivityIndicatorVisible=YES;
    [[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleBlackOpaque animated:NO];
    //Set Apps navbar
    self.title=@"Trip Planer";

    UINavigationBar *navBar= self.navigationController.navigationBar;
    //[navBar setTintColor:[UIColor colorWithRed:0.102 green:0.498 blue:0.812 alpha:1] /*#1a7fcf*/];

    UIImage *imagebar = [UIImage imageNamed:@"Menu-Bar"];
    [navBar setBackgroundImage:imagebar forBarMetrics:UIBarMetricsDefault];

    ////set rightbutton menus
    UIButton *rightButton = [[UIButton alloc] init];
    rightButton.frame=CGRectMake(0,100.0f,23,23);
    [rightButton setBackgroundImage:[UIImage imageNamed: @"Filters"] forState:UIControlStateNormal];
    rightButton.highlighted=false;
    [rightButton addTarget:self action:@selector(showFilters:) forControlEvents:UIControlEventTouchDown];

    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:rightButton];
    navBar.layer.zPosition=1;

    [rightButton release];
}

我使用 TSMiniwebBrowser 作为模态窗口

-(void) initTitleBar {
    UIBarButtonItem *buttonDone = [[UIBarButtonItem alloc] initWithTitle:modalDismissButtonTitle style:UIBarButtonItemStyleBordered target:self action:@selector(dismissController)];

    UINavigationItem *titleBar = [[UINavigationItem alloc] initWithTitle:@""];
    titleBar.leftBarButtonItem = buttonDone;


    CGFloat width = self.view.frame.size.width;
    UIImage *navbarPortrait = [[UIImage imageNamed:@"Menu-Bar"]
                               resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    navigationBarModal = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, width, 44)];
    [[UINavigationBar appearance] setBackgroundImage:navbarPortrait
                                       forBarMetrics:UIBarMetricsDefault];
    navigationBarModal.layer.zPosition=700.0;
    NSLog(@"%f",navigationBarModal.layer.zPosition);
    //navigationBar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin;
    navigationBarModal.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    [navigationBarModal pushNavigationItem:titleBar animated:NO];

    [self.view addSubview:navigationBarModal];
}

主要问题是 rootviewcontroller 上的导航栏总是覆盖 TSMiniWeb Browser 事件我将 TSminiBrowser Navbar 的 zposition 更改为大于 viewcontroller .. mycode 有什么问题吗?

4

1 回答 1

0

addSubview不是呈现模态视图控制器的正确方法。我建议你阅读 iOS 的 View Controller Programming Guide,特别是Presenting View Controllers from Other View Controllers

于 2012-11-02T14:26:09.887 回答