【发布时间】:2016-02-25 18:44:07
【问题描述】:
我有一个嵌套的 UIStackView,当我按下一个按钮时,它就会被实例化。更详细地说,我有一个 UIStackView,它遍历一个充满 CustomUIStackViews 的 NSMutableArrayList 并将它们添加为排列的Subviews。当 CustomUIStackViews 启动时,它们还会遍历自己的 NSMutableArrayList 填充 UIViews 并将它们添加为排列的Subviews。
奇怪的是,在我所有的 for 循环都执行之后,我有一个 NSLog:
NSLog(@"parentstackview height is %f",_parentStackView.frame.size.height);
它返回一个 0(它不应该,高度应该是 1861 之后所有的堆栈视图都显示出来,他们在模拟器中可见)。
但是如果我创建这个方法:
- (void)testMethod{
NSLog(@"parentstackview height is %f",_parentStackView.frame.size.height);
}
并将之前的 NSLog 替换为:
[self performSelector:@selector(testMethod) withObject:nil afterDelay:1.0];
然后在延迟 1 秒后返回 1861。
为什么 1 秒的延迟会产生影响?
【问题讨论】:
标签: ios objective-c autolayout uistackview