0

これは、このスレッドの継続/代替です: popToRootViewControllerAnimated problemは、より構造化された理解しやすい方法で問題/間違いを整理します。

VC3 で戻るボタンを押すと、VC1 に戻りたいです。

私は次の設定をしています:

ここに画像の説明を入力

次のコード:

VC1:

@implementation ViewController
- (IBAction)myButton1:(id)sender {

//Call InformationViewController for Quick Game
[self performSegueWithIdentifier:@"toVC2" sender:self];


}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end

VC2:

@implementation nrTwoViewController
- (IBAction)myButton2:(id)sender {
//Call InformationViewController for Quick Game
[self performSegueWithIdentifier:@"toVC3" sender:self];

}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
}
return self;
}

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end

VC3:

@implementation nrThreeViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
}
return self;
}

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.


}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

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


@end

ルート (VC1) ではなく VC2 にのみポップし、VC3 で [戻る] ボタンを押すと次のメッセージが表示されます。

2013-10-15 08:36:08.479 segueTest[44153:a0b] nested pop animation can result in corrupted navigation bar
2013-10-15 08:36:08.831 segueTest[44153:a0b] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.

また、提案されているように、UINavigationBarDelegate を追加しようとしました。

@interface nrThreeViewController : UIViewController <UINavigationBarDelegate>

...と:

- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item {
[self.navigationController popToRootViewControllerAnimated:YES];
return NO;
}

結果:

コンソールにメッセージが表示されずに、VC3 から VC2 のみにポップされました。

4

1 に答える 1