gpt4 book ai didi

ios - 如果使用自动布局,何时检查呈现的 viewController 是否属于类型

转载 作者:行者123 更新时间:2023-12-01 16:30:16 25 4
gpt4 key购买 nike

这是我用来在 viewDidLoad 中设置约束的代码:

if (self.presentingViewController?.isKindOfClass(GameViewController) != nil) {
print("huhu")
self.bottomViewToBottomConstraint.constant = -367
self.bottomViewToHiddenButtonConstraint.constant = 401
} else {
self.bottomViewToBottomConstraint.constant = -200
self.bottomViewToHiddenButtonConstraint.constant = 200
print("No presenting viewController")
}

我收到的消息是没有显示 viewController。如您所见,我还设置了不同的动画约束,具体取决于呈现 viewController 的类。那么在什么时候已经知道谁在展示 View Controller 并且也是设置约束的正确时间呢?感谢帮助

最佳答案

就这么简单:

After you add the bottomView to it's superview.



试试 viewWillAppear 方法:
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];

// here
}

关于ios - 如果使用自动布局,何时检查呈现的 viewController 是否属于类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32038481/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com