- 我有一個網頁在兩次的tableview,但一次顯示一個的tableView;
- 我創建了一個查看tableview的標題視圖(稱爲 headerView);
- 我設置headerView當前的tableView(A)作爲 tableHeaderView,以及用於另一的tableView(B)作爲 tableHeaderView(節目A)設定爲零;
- 我點擊一個按鈕顯示的tableView(B),所以我設置爲零作爲 tableHeaderView爲的tableView(A),設置headerView作爲 tableHeaderView爲的tableView(B);
當我爲tableView(N)設置headerView錯誤即將到來,詳情請看下面的日誌。 控制檯錯誤日誌如下:
2015-12-04 10:15:18.777 XXXApp[1223:360705] Unable to simultaneously satisfy constraints.
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.
(
"<NSLayoutConstraint:0x7f8f7bdd74b0 H:|-(10)-[UIView:0x7f8f7bdbbe00] (Names: '|':MarketGoodsDetail:0x7f8f7bdb92d0)>",
"<NSLayoutConstraint:0x7f8f7bdd7500 H:[UIView:0x7f8f7bdbbe00]-(10)-| (Names: '|':MarketGoodsDetail:0x7f8f7bdb92d0)>",
"<NSLayoutConstraint:0x7f8f7bdd8fa0 H:|-(0)-[MarketGoodsDetail:0x7f8f7bdb92d0] (Names: '|':UIView:0x7f8f7bdd8b70)>",
"<NSLayoutConstraint:0x7f8f7bdd8ff0 H:[MarketGoodsDetail:0x7f8f7bdb92d0]-(0)-| (Names: '|':UIView:0x7f8f7bdd8b70)>",
"<NSLayoutConstraint:0x7f8f7bddac40 H:[UIView:0x7f8f7bdd8b70]-(0)-| (Names: '|':UIView:0x7f8f7bdda860)>",
"<NSLayoutConstraint:0x7f8f7bddace0 H:|-(0)-[UIView:0x7f8f7bdd8b70] (Names: '|':UIView:0x7f8f7bdda860)>",
"<NSLayoutConstraint:0x7f8f7e0c6d90 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7f8f7bdda860(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7f8f7bdd7500 H:[UIView:0x7f8f7bdbbe00]-(10)-| (Names: '|':MarketGoodsDetail:0x7f8f7bdb92d0)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
由於傑森 - 賈勒特的博客http://staxmanade.com/2015/06/debugging-ios-autolayout-issues/我打印,我認爲它造成如下問題的看法的自動佈局信息:
po [0x7f8f7bdb92d0 recursiveDescription]
<MarketGoodsDetail: 0x7f8f7bdb92d0; frame = (0 0; 375 127); autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x7f8f7bdb9760>>
| <UILabel: 0x7f8f7bdb9b80; frame = (10 8.5; 37.5 12); text = '(廣貴所)'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdb9780>>
| | <_UILabelContentLayer: 0x7f8f7bfc4090> (layer)
| <UILabel: 0x7f8f7bdba820; frame = (10 22.5; 121.5 36); text = '2892.00'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdb9f10>>
| <UILabel: 0x7f8f7bdbb460; frame = (237.5 35; 52.5 20.5); text = '-13.00'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbb660>>
| <UILabel: 0x7f8f7bdbb9c0; frame = (307 35; 58 20.5); text = '-0.45%'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbbbc0>>
| <UIView: 0x7f8f7bdbbe00; frame = (10 63.5; 355 0.5); autoresize = RM+BM; layer = <CALayer: 0x7f8f7bdbbf70>>
| <UILabel: 0x7f8f7bdbc0b0; frame = (10 76; 26 16); text = '今開'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbc2b0>>
| | <_UILabelContentLayer: 0x7f8f7e0c2a90> (layer)
| <UILabel: 0x7f8f7bdbcd70; frame = (42 76; 51.5 16); text = '2905.00'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbcf70>>
| <UILabel: 0x7f8f7bdbd180; frame = (10 102; 26 16); text = '昨收'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbd380>>
| | <_UILabelContentLayer: 0x7f8f7e0c1640> (layer)
| <UILabel: 0x7f8f7bdbd590; frame = (42 102; 51.5 16); text = '2905.00'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbd790>>
| <UILabel: 0x7f8f7bdbd9a0; frame = (281.5 76; 26 16); text = '最高'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbdba0>>
| | <_UILabelContentLayer: 0x7f8f7e0c1ea0> (layer)
| <UILabel: 0x7f8f7bdbddb0; frame = (313.5 76; 51.5 16); text = '2909.00'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbdfb0>>
| <UILabel: 0x7f8f7bdbe1c0; frame = (281.5 102; 26 16); text = '最低'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbe3c0>>
| | <_UILabelContentLayer: 0x7f8f7e0c4e60> (layer)
| <UILabel: 0x7f8f7bdbe5d0; frame = (313.5 102; 51.5 16); text = '2889.00'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbe7d0>>
| <UIView: 0x7f8f7bdbe9e0; frame = (146 76; 83.5 42); autoresize = RM+BM; layer = <CALayer: 0x7f8f7bdbeb50>>
| | <UILabel: 0x7f8f7bdbeb70; frame = (0 0; 26 16); text = '買進'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbed70>>
| | | <_UILabelContentLayer: 0x7f8f7e0c4e90> (layer)
| | <UILabel: 0x7f8f7bdbef80; frame = (0 26; 26 16); text = '賣出'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdd5990>>
| | | <_UILabelContentLayer: 0x7f8f7e0c4b70> (layer)
| | <UILabel: 0x7f8f7bdd5b80; frame = (32 0; 51.5 16); text = '2898.00'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdd5d80>>
| | <UILabel: 0x7f8f7bdd5f90; frame = (32 26; 51.5 16); text = '2892.00'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdd6190>>
它是超級視圖自動佈局:
po [[0x7f8f7bdb92d0 superview] recursiveDescription]
<UIView: 0x7f8f7bdd8b70; frame = (0 0; 375 127); autoresize = RM+BM; layer = <CALayer: 0x7f8f7bdd8ce0>>
| <MarketGoodsDetail: 0x7f8f7bdb92d0; frame = (0 0; 375 127); autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x7f8f7bdb9760>>
| | <UILabel: 0x7f8f7bdb9b80; frame = (10 8.5; 37.5 12); text = '(廣貴所)'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdb9780>>
| | | <_UILabelContentLayer: 0x7f8f7bfc4090> (layer)
| | <UILabel: 0x7f8f7bdba820; frame = (10 22.5; 121.5 36); text = '2892.00'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdb9f10>>
| | <UILabel: 0x7f8f7bdbb460; frame = (237.5 35; 52.5 20.5); text = '-13.00'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbb660>>
| | <UILabel: 0x7f8f7bdbb9c0; frame = (307 35; 58 20.5); text = '-0.45%'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbbbc0>>
| | <UIView: 0x7f8f7bdbbe00; frame = (10 63.5; 355 0.5); autoresize = RM+BM; layer = <CALayer: 0x7f8f7bdbbf70>>
| | <UILabel: 0x7f8f7bdbc0b0; frame = (10 76; 26 16); text = '今開'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbc2b0>>
| | | <_UILabelContentLayer: 0x7f8f7e0c2a90> (layer)
| | <UILabel: 0x7f8f7bdbcd70; frame = (42 76; 51.5 16); text = '2905.00'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbcf70>>
| | <UILabel: 0x7f8f7bdbd180; frame = (10 102; 26 16); text = '昨收'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbd380>>
| | | <_UILabelContentLayer: 0x7f8f7e0c1640> (layer)
| | <UILabel: 0x7f8f7bdbd590; frame = (42 102; 51.5 16); text = '2905.00'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbd790>>
| | <UILabel: 0x7f8f7bdbd9a0; frame = (281.5 76; 26 16); text = '最高'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbdba0>>
| | | <_UILabelContentLayer: 0x7f8f7e0c1ea0> (layer)
| | <UILabel: 0x7f8f7bdbddb0; frame = (313.5 76; 51.5 16); text = '2909.00'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbdfb0>>
| | <UILabel: 0x7f8f7bdbe1c0; frame = (281.5 102; 26 16); text = '最低'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbe3c0>>
| | | <_UILabelContentLayer: 0x7f8f7e0c4e60> (layer)
| | <UILabel: 0x7f8f7bdbe5d0; frame = (313.5 102; 51.5 16); text = '2889.00'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbe7d0>>
| | <UIView: 0x7f8f7bdbe9e0; frame = (146 76; 83.5 42); autoresize = RM+BM; layer = <CALayer: 0x7f8f7bdbeb50>>
| | | <UILabel: 0x7f8f7bdbeb70; frame = (0 0; 26 16); text = '買進'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdbed70>>
| | | | <_UILabelContentLayer: 0x7f8f7e0c4e90> (layer)
| | | <UILabel: 0x7f8f7bdbef80; frame = (0 26; 26 16); text = '賣出'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdd5990>>
| | | | <_UILabelContentLayer: 0x7f8f7e0c4b70> (layer)
| | | <UILabel: 0x7f8f7bdd5b80; frame = (32 0; 51.5 16); text = '2898.00'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdd5d80>>
| | | <UILabel: 0x7f8f7bdd5f90; frame = (32 26; 51.5 16); text = '2892.00'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f8f7bdd6190>>
誰能告訴我哪個約束導致了這個問題?感謝您的幫助!
視圖是否正確顯示,並且您希望錯誤消失還是未按照您希望的方式顯示? – beyowulf
@beyowulf視圖呈現正確,但報告錯誤信息我張貼,如何讓錯誤消失? – Raniys
你怎麼隱藏你不想展示的表格視圖?偶然設置它的寬度爲0嗎? – kleezy