x=%f, y=%f-6ren">
gpt4 book ai didi

ios - IBOutlet NSLayoutConstraint 没有给出值

转载 作者:行者123 更新时间:2023-11-28 18:56:16 27 4
gpt4 key购买 nike

我创建了自动布局约束IBOutlet 这里是屏幕截图

enter image description here

enter image description here

enter image description here

这是代码

-(void)viewDidAppear:(BOOL)animated {

NSLog(@"View=> x=%f, y=%f, w=%f, h=%f", self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width ,self.view.frame.size.height);

NSLog(@"V=> x=%f, y=%f, w=%f, h=%f", self.v.frame.origin.x, self.v.frame.origin.y, self.v.frame.size.width ,self.v.frame.size.height);

NSLog(@"Constant=> w=%f, h=%f", self.vWidth.constant, self.vHeight.constant);
}

这是输出

View=> x=0.000000, y=0.000000, w=414.000000, h=736.000000
V=> x=0.000000, y=536.000000, w=414.000000, h=200.000000
Constant=> w=0.000000, h=200.000000

问题一:使用自动布局时,获取像这样的框架属性是否正确 self.v.frame.size.width, self.v.frame.size.height 或者我应该使用 self.vWidth.constant, self.vHeight.constant?

问题二:为什么我在 NSLog(@"Constant=> w=%f, h=%f", self.vWidth.constant, self.vHeight.constant); 中的宽度为零?

最佳答案

您将在 viewDidLayoutSubviews 中获取值。

关于ios - IBOutlet NSLayoutConstraint 没有给出值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32266008/

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