我有两个视图控制器。当我在'A'视图控制器中呈现模态'B'视图控制器然后关闭它时,在'A'视图控制器中查看将其帧从{{0,0},{320,480}}更改为{{0,0 },{0,0}}。所有子视图都不会更改其位置,但不会响应。
控制器'A'代码:
- (void)viewDidLoad {
[super viewDidLoad];
self.view.translatesAutoresizingMaskIntoConstraints = NO;
self.logoImageView.translatesAutoresizingMaskIntoConstraints = NO;
self.view.backgroundColor = WHITE_C;
buttonHeight = self.view.frame.size.height/5;
buttonYPosition = self.view.frame.size.height - buttonHeight;
buttonW = self.view.frame.size.width/2;
[self configureButtons];
}
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
- (void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
- (void) auth {
[self performSegueWithIdentifier:segueToAuth sender:self];
}
控制器'B'代码:
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationController.navigationBar.barTintColor = ORANGE_C;
UIImage * backArrow = [UIImage imageNamed:@"back_orange.png"];
UIBarButtonItem * back = [[UIBarButtonItem alloc] initWithImage:backArrow style:UIBarButtonItemStylePlain target:self action:@selector(backToWelcomeScreen)];
[self.navigationItem setLeftBarButtonItems:@[back]];
}
#pragma mark - Buttons
- (void) backToWelcomeScreen {
[self dismissViewControllerAnimated:YES completion:nil];
}
有人知道为什么会这样吗?
我尝试按viewDidAppear:
设置帧,但没有任何反应。
答案 0 :(得分:1)
问题在于:
self.view.translatesAutoresizingMaskIntoConstraints = NO;
self.logoImageView.translatesAutoresizingMaskIntoConstraints = NO;
删除应用后效果很好。
答案 1 :(得分:0)
您的分隔符视图宽度和高度取决于按钮大小,并且您只在下次设置视图框架时在viewdidload中设置按钮大小按钮大小为nil