Using the UINavigationController, jump from page A(UIViewController A) to page B (UIViewController B), and page B(UIViewController B) clicks back. When page A(UIViewController A) is returned, the view of page A(UIViewController A) moves down as a whole, and the top turns black.
Reproduce steps: step1: Set “self.edgesForExtendedLayout = UIRectEdgeNone;” in the method “viewDidLoad” UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
// step1
self.edgesForExtendedLayout = UIRectEdgeNone;
}
step2:Set “ self.navigationController.navigationBarHidden = YES;” in the method “viewWillAppear” UIViewController
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// step2
self.navigationController.navigationBarHidden = YES;
}
step3:Set “self.navigationController.navigationBarHidden = NO;” in the method “viewWillDisappear” UIViewController
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
// step3
self.navigationController.navigationBarHidden = NO;
}
step4:Set “[self.navigationControllerpopViewControllerAnimated:NO];” in the method “viewWillDisappear” UIViewController When page is returned
- (void)click {
UIViewController *vc = [[UIViewController alloc] init];
vc.view.backgroundColor = [UIColor redColor];
[self.navigationController pushViewController:vc animated:YES];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// step4,animated NO
[self.navigationController popViewControllerAnimated:NO];
});
}
The test found that the UIView was normal after removing the "self.edgesForExtendedLayout=UIRectEdgeNone" setting.