2013-04-05 67 views
0

我似乎有一些問題設置我的約束編程爲我使用的UITableView。我的嘗試是在下面,並嘗試使用translatesAutoresizingMaskIntoConstraints可能的每個組合。以編程方式嘗試NSLayoutContraint會導致「無法同時滿足約束」。

self.view.translatesAutoresizingMaskIntoConstraints = NO; 
    _tableView.translatesAutoresizingMaskIntoConstraints = NO; 
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-100-[_tableView]-20-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_tableView)]]; 

我只是想在UIViewController的UITableView的開始和結尾添加一個空格。任何人都可以幫忙嗎?

長而長的錯誤在下面。

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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x75c8500 h=-&- v=-&- UITableView:0x799e400.midY == UIView:0x71a4ec0.midY>", 
    "<NSLayoutConstraint:0x71a5800 V:[UITableView:0x799e400]-(20)-| (Names: '|':UIView:0x71a4ec0)>", 
    "<NSLayoutConstraint:0x71a5a60 V:|-(100)-[UITableView:0x799e400] (Names: '|':UIView:0x71a4ec0)>" 
) 

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x71a5800 V:[UITableView:0x799e400]-(20)-| (Names: '|':UIView:0x71a4ec0)> 

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. 
2013-04-04 20:06:57.648 New eCard[29731:c07] 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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x75c8540 h=-&- v=-&- UITableView:0x799e400.height == UIView:0x71a4ec0.height>", 
    "<NSAutoresizingMaskLayoutConstraint:0x75c8500 h=-&- v=-&- UITableView:0x799e400.midY == UIView:0x71a4ec0.midY>", 
    "<NSLayoutConstraint:0x71a5a60 V:|-(100)-[UITableView:0x799e400] (Names: '|':UIView:0x71a4ec0)>" 
) 

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x71a5a60 V:|-(100)-[UITableView:0x799e400] (Names: '|':UIView:0x71a4ec0)> 

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. 
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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x75c8540 h=-&- v=-&- UITableView:0x799e400.height == UIView:0x71a4ec0.height>", 
    "<NSAutoresizingMaskLayoutConstraint:0x75c8500 h=-&- v=-&- UITableView:0x799e400.midY == UIView:0x71a4ec0.midY>", 
    "<NSLayoutConstraint:0x71a5800 V:[UITableView:0x799e400]-(20)-| (Names: '|':UIView:0x71a4ec0)>" 
) 

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x71a5800 V:[UITableView:0x799e400]-(20)-| (Names: '|':UIView:0x71a4ec0)> 

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. 
+0

你創建IB或代碼此表視圖。它表明你在表視圖和超視圖之間有一箇中間y約束。 – rdelmar 2013-04-05 02:24:59

+0

哦,我真的很抱歉,我可以發誓,我把那部分放在那裏。我用IB。 – 2013-04-05 02:38:28

+1

如果您使用IB,爲什麼在代碼中設置約束?當你在IB中創建對象時,你會得到Xcode放入的約束,並且它們可能與你正在添加的約束衝突。 – rdelmar 2013-04-05 02:43:39

回答

相關問題