我对这种行为感到有点困惑,但我现在无法修复它,我需要帮助。
我有控制器,我将其包装到UINavigationController
- (void) buttonPressed {
NewKeyInformationViewController *addKeyViewController = [[NewKeyInformationViewController alloc]initWithNibName:NSStringFromClass([NewKeyInformationViewController class]) bundle:nil];
addKeyViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addKeyViewController];
navigationController.navigationBar.translucent = NO;
[self presentViewController:navigationController animated:YES completion:nil];
}
演示动画结束后,我看到leftBarButtonItem跳转到右边。
我可以在iOS 8.4上看到这种行为(iOS 7.1效果很好)
信息:
我以编程方式添加leftBarButtonItem:
// NewKeyInformationViewController.m
- (void)addCloseButton {
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(closeButtonPressed:)];
}
- (void)closeButtonPressed:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self addCloseButton];
self.navigationItem.title = @"some title";
// and many items here
}
思想:
我不明白这种行为,因为我的演示风格(控制器包裹在导航控制器中,这个三明治呈现为模态) 不依赖于它周围的任何东西作为环境(例如,呈现这个模态控制器的控制器)