0

私のアプリケーションでは、関数 [self.navigationCotroller presentModalViewController:nextVC animation:YES]; を使用しようとしました。ただし、次のビューに移動すると、サブビューが画面全体を満たします(もちろんそうです)そして問題は、ビューを元に戻すバーボタンをどのように追加できますか?

私は使用しようとしました

  1. self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"back" style:UIBarButtonItemStyleDone target:self action:@selector(Go)];
    

    関数viewdidLoadで、しかしそれは機能しませんでした.バーもボタンも表示されませんでした

  2. UINavigationBar *bb =  [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 44)];
    self.NVBar = bb;
    [self.view addSubview:bb];
    

ただし、新しいナビゲーションバー ---NVBar にバーボタンを追加する方法がわかりません

解決策を教えてください。

4

2 に答える 2

0

[self.navigationController pushViewController:picker animated:YES];次の VC をプッシュするために使用する場合、ナビゲーション バーは上部に留まる必要があります。その後、 ` [self.navigationController popViewControllerAnimated:YES]; でポップバックできます。

ナビゲーション バーを使用してモーダル ビューから戻るのは、非常に型破りです。`

于 2013-05-19T07:05:49.343 に答える
0

ナビゲーション バーを自動的に含めるには、新しいビュー コントローラーをポップする必要があります。

上記のコードが入っているView Controllerでは、

//*** Hook up four buttons to these actions and play around with it for a 
//*** better sense of what is going on.    
//*** JSBViewController is the name of my test class
//*** You should use your ViewController class that you are currently coding so
//*** you can see the difference of pop/push versus present/dismiss inside of a            
//*** navigation controller
-(IBAction)push:(id)sender
{
  JSBViewController * viewController = [self.storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([JSBViewController class])];
  [self.navigationController pushViewController:viewController animated:YES];
}
-(IBAction)pop:(id)sender
{
  [self.navigationController popViewControllerAnimated:YES];

}
-(IBAction)present:(id)sender
{
  JSBViewController * viewController = [self.storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([JSBViewController class])];
  [self presentViewController:viewController animated:YES completion:nil];
}
-(IBAction)dismiss:(id)sender
{
  [self dismissViewControllerAnimated:YES completion:nil];
}

探している動作については、プッシュ メソッドを使用する必要があります。
[self.navigationController pushViewController:viewController animated:YES];

于 2013-05-19T05:58:35.430 に答える