我創建的auto layout constraints
的IBOutlet
值這裏的屏幕截圖IBOutlet中NSLayoutConstraint不給
這裏是代碼
-(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
問題1: 使用auto layouts
是正確的得到這樣self.v.frame.size.width
,self.v.frame.size.height
幀的性能,或者我應該使用self.vWidth.constant
,self.vHeight.constant
?
問題2: 爲什麼我在這個NSLog(@"Constant=> w=%f, h=%f", self.vWidth.constant, self.vHeight.constant);
的零寬度?
只是一個提示,這樣可以節省您打印出rects時的一些輸入。您可以使用[NSValue valueWithCGRect:self.view.frame]來打印x,y,寬度和高度。 – Oblieapps
甚至更好; NSStringFromCGRect(<#CGRect rect#>) –
非常感謝你的提示:) –