-1

rootview Controllerにナビゲーションバーを作成しました

- (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モーダル ビュー コントローラーを表示する正しい方法ではありません。View Controller Programming Guide for iOS、特にPresenting View Controllers from Other View Controllersを読むことをお勧めします

于 2012-11-02T14:26:09.887 に答える