2017-12-15 3 views
0

私はUIImagePickerControllerのカスタムオーバーレイの一部として情報ボタンを持っています。あなたはそれをクリックすると、私は(UIImagePickerController「プレゼンテーション」中に隠されている)ナビゲーションバーの外観を設定し、新しいビューコントローラプッシュ:Obj C:ビューの後にナビゲーションバーのボタンが表示されます

- (IBAction)infoButtonPressed:(id)sender { 
    CameraHelpViewController *helpController = [[[CameraHelpViewController alloc] initWithNibName:@"CameraHelpViewController" bundle:nil] autorelease]; 

    [[UINavigationBar appearance] setBarStyle:UIBarStyleBlackTranslucent]; 
    [[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]]; 
    [[UINavigationBar appearance] setTranslucent:NO]; 
    [ipc pushViewController:helpController animated:NO]; 

} 

CameraHelpViewController.m

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    // Web view loading 
    NSString *basePath = [[NSBundle mainBundle] resourcePath]; 
    basePath = [basePath stringByReplacingOccurrencesOfString:@"/" withString:@"//"]; 
    basePath = [basePath stringByReplacingOccurrencesOfString:@" " withString:@"%20"];  
    NSString *HTMLfile =[[NSBundle mainBundle] pathForResource:@"camera_help" ofType:@"html"]; 
    NSError *error; 
    NSString *stringFromPath = [[[NSString alloc] initWithContentsOfFile:HTMLfile encoding:NSUTF8StringEncoding error:&error] autorelease];  

    [webView loadHTMLString:stringFromPath baseURL:[NSURL URLWithString:[NSString stringWithFormat:@"file:/%@//", basePath]]]; 
    webView.backgroundColor = [UIColor blackColor];  
    webView.opaque = NO; // Prevents the white flash from occurring  
    [_activityIndicator startAnimating]; 
} 

//UPDATE: 
- (void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 
    [self.navigationController setNavigationBarHidden:NO animated:animated]; 
} 

- (void)viewDidDisappear:(BOOL)animated { 
    [super viewDidDisappear:animated]; 
    [self.navigationController setNavigationBarHidden:YES animated:animated]; 
} 

UPDATEを@ryancrunchiのコードを使用しているため、ナビゲーションバーのボタンは表示されません。代わりに、ナビゲーションバーは、ビューがロードされてから数秒で上に移動します。

enter image description here

私は、新しいビューが表示される前に、ナビゲーションバーが完全に設定されているしたいと思います。どうやってやるの?

答えて

0

これらの行を使用すると、 [ipc setNavigationBarHidden:NO animated:YES]; [ipc pushViewController:helpController animated:NO]; ナビゲーションバーにアニメーションが表示されますが、helpControllerはアニメーションなしで表示されます。したがって、helpControllerは、それ自体がアニメーションを再生しているナビゲーションバーの前に表示されます(遅延表示)。 あなたは、まったくのアニメーションをしたいあなたのCameraHelpViewController[ipc setNavigationBarHidden:NO animated:NO];を入れていない場合は、次の

- (void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 
    [ipc setNavigationBarHidden:NO animated:animated]; 
    // or 
    [self.navigationController setNavigationBarHidden:NO animated:animated]; 
} 

と表示が消えたときにバーを非表示:

- (void)viewDidDisappear:(BOOL)animated { 
    [super viewDidDisappear:animated]; 
    [ipc setNavigationBarHidden:YES animated:animated]; 
    // or 
    [self.navigationController setNavigationBarHidden:YES animated:animated]; 
} 
+0

を私はアニメーションを使用しない場合は、私がYES '入れます'?私はあなたの 'viewWillAppear'を実装しましたが、ボタンはまだビューの後に設定されています。 (また 'CameraHelpViewController'は' ipc'にアクセスできない) – Matt

+0

ofc、アニメーションなしの 'animated:NO'が編集されました。 'ipc'にアクセスできない場合は、' self.navigationController'を使用してください。 – ryancrunchi

+0

ビューが表示された後でもボタンが表示されています – Matt

関連する問題