我有一個需要並排佈局兩個UILabels的自定義單元。兩個標籤的寬度都是動態的,可以換行。不能在動態寬度的Tablecell中並排AutoLayout兩個UILabels
我已經定義的自動版式下下列情況
- 滾動的細胞和包含它的部分,所以,這是所有在屏幕上失敗。
- 將設備旋轉到橫向(需要足夠大的視圖才能顯示單元格)
- 向後旋轉,左側標籤將被壓縮。
如果整個細胞和含科不上輪換佈局之前屏幕不會失敗
這裏有幾個工作呢截圖和旋轉後
這與以下約束佈局
this.ContentView.AddConstraint(
NSLayoutConstraint.Create(
this.TextLabel, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this.ContentView, NSLayoutAttribute.Left,
1.0f, (nfloat)LeftRightPadding));
this.ContentView.AddConstraint(
NSLayoutConstraint.Create(
this.TextLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this.ContentView, NSLayoutAttribute.Top,
1.0f, (nfloat)TopAndBottomPadding));
this.ContentView.AddConstraint(
NSLayoutConstraint.Create(
this.TextLabel, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, this.ContentView, NSLayoutAttribute.Bottom,
1.0f, 0 - (nfloat)TopAndBottomPadding));
this.ContentView.AddConstraint(
NSLayoutConstraint.Create(
this.DetailTextLabel, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this.ContentView, NSLayoutAttribute.Right,
1.0f, 0 - (nfloat)LeftRightPadding));
this.ContentView.AddConstraint(
NSLayoutConstraint.Create(
this.DetailTextLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this.ContentView, NSLayoutAttribute.Top,
1.0f, (nfloat)TopAndBottomPadding));
this.ContentView.AddConstraint(
NSLayoutConstraint.Create(
this.DetailTextLabel, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, this.ContentView, NSLayoutAttribute.Bottom,
1.0f, 0 - (nfloat)TopAndBottomPadding));
this.ContentView.AddConstraint(
NSLayoutConstraint.Create(
this.DetailTextLabel, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this.TextLabel, NSLayoutAttribute.Right,
1.0f,
10));
如何阻止擠壓左側標籤?
增加左壓縮阻力? –