所以,球員等景觀,隱藏查看和重新定位與自動版式
我有一個包含幾個信息的輪廓圖。其中一些不必設置,例如傳記。因此,根據它的設置,我想隱藏Biografie View(checkout截圖)並重新定位UserData視圖和ActivityData視圖,並更改其超級視圖的大小以填充Biografie視圖所創建的空間。
這裏是我的我的TableViewHeader的實際結構:
另一點,我要關心的是,該的UILabel必須mutliline和適應其內容。
所以我的問題:
- 如何重新定位的UserData & ActivityData查看填補隱藏BiografieView作出 空間?
- 如何製作Biografie 視圖高度是否符合UILabels文本?
請記住,我正在使用Autolayout。所以我必須使用約束條件來修改位置嗎?
說實話..基本上它應該像Instagram,當添加一個Biografie。我希望我做到了我想清楚什麼..
編輯1
我已經試過你的建議達明,但沒有正在發生變化:
NSLog(@"Height %f, Width %f", self.labelBiografie.frame.size.height, self.labelBiografie.frame.size.width);
if ([self.profileUser objectForKey:kGSUserBiografieKey]) {
self.labelBiografie.text = [self.profileUser objectForKey:kGSUserBiografieKey];
[self.labelBiografie sizeToFit];
}else{
[self.labelBiografie setHidden:YES];
[self.countContainer setConstraintConstant:-self.labelBiografie.frame.size.height forAttribute:NSLayoutAttributeCenterY];
[self.tableHeaderViewChildVIew setConstraintConstant:-self.labelBiografie.frame.size.height forAttribute:NSLayoutAttributeHeight];
self.tableView.tableHeaderView = self.tableHeaderViewChildVIew;
}
編輯2:
使用該項目(UIView-UpdateAutoLayoutConstraints )我得到以下方法的錯誤:
第56行:[self hideView:hidden byAttribute:NSLayoutAttributeHeight];
線85:[self setConstraintConstant:0 forAttribute:attribute];
第23行:
[self.superview addConstraint: [NSLayoutConstraint constraintWithItem:self attribute:attribute relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0f constant:constant]];
錯誤:
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x8c1b8e0 V:|-(0)-[UIButton:0x8c6fb40] (Names: '|':UIView:0x8c6f630)>",
"<NSLayoutConstraint:0x8c19dc0 V:[UIButton:0x8c6fb40(100)]>",
"<NSLayoutConstraint:0x8c1d740 V:[UIButton:0x8c6fb40]-(NSSpace(8))-[UILabel:0x8c70900]>",
"<NSLayoutConstraint:0x8c20df0 V:[UILabel:0x8c70900]-(NSSpace(8))-[UIView:0x8c16a00]>",
"<NSLayoutConstraint:0x8c20fa0 V:[UIView:0x8c16a00(40)]>",
"<NSLayoutConstraint:0x8c23790 V:[UIView:0x8c16a00]-(0)-| (Names: '|':UIView:0x8c6f630)>",
"<NSAutoresizingMaskLayoutConstraint:0x8c78e60 h=--& v=--& V:[UIView:0x8c6f630(217)]>",
"<NSLayoutConstraint:0x8c5d000 V:[UILabel:0x8c70900(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x8c20df0 V:[UILabel:0x8c70900]-(NSSpace(8))-[UIView:0x8c16a00]>
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
此錯誤表明了對示範項目的開箱,在我的項目上,當我隱藏視圖時,它也會返回..
聽起來不錯...會檢查出來..給我時間.. – SaifDeen
你有Q2的答案嗎? – SaifDeen
在你的生物視圖中你只有一個UILabel嗎? –