iOS:使用由“自动布局”约束的框架来创建子视图

时间:2016-03-21 10:55:13

标签: ios objective-c iphone autolayout

我使用IB和Auto Layout创建一个名为boundView的视图,然后在控制器中调用[self.boundView layoutIfNeeded],然后我将self.boundView.frame.size传递给一个方法来生成boundView&#39的大小; s子视图CardView。然后使用

 PlayingCardView *playingCardView = [[PlayingCardView alloc]initWithFrame:frame];

以编程方式创建子视图。我确实使用NSLog来检查子视图的大小是否小于superview。但是当我使用[self.boundView addSubview:CardView]添加子视图时。它比superview大! 坐标有问题吗?或者是因为我将自动布局与我按代码创建的视图结合起来了?

1 个答案:

答案 0 :(得分:1)

你在做什么?如果它在val read_file2 = sc.textFile("/home/hari/sample_data_exp/extract_column_only.csv") read_file2.collect() val tmp1 = read_file2.map { line => val parts = line.split(',') parts.drop(3).take(1) 中,那么自动布局大小尚未计算。尝试在viewDidLoad中完成。