2013-02-21 3 views
3

UIViewController (UINavigationController 내부에있는 UITabBarController 내부)에 제약 조건을 사용하는 방법을 알아 내려고 노력 중입니다 ... 1000 개가 넘는 단어가 여기에 있습니다. .ios6 autolayout 제약

Portrait Lanscape

는 사실, 첫 번째는 두 번째는 휴식을 취합니다 광고 (그래서 50 픽셀 가로 세로 32px에서), 그리고 마지막으로있는 tableView이며, 100 픽셀 높이에 상관없이 방향이다 . 지금까지 여기

내 코드입니다 :

PMMainProfilHeader *profilHeader = [[PMMainProfilHeader alloc] init]; 
    [self.view addSubview:profilHeader]; 
    [profilHeader release]; 

    UIView *adTest = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; 
    adTest.backgroundColor = [UIColor redColor]; 
    [self.view addSubview:adTest]; 
    [adTest release]; 

    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
    [self.view addSubview:_tableView]; 
    [_tableView release]; 

    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[profilHeader]-0-|" 
                     options:0 
                     metrics:nil 
                     views:NSDictionaryOfVariableBindings(profilHeader)]]; 
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[adTest]-0-|" 
                     options:0 
                     metrics:nil 
                     views:NSDictionaryOfVariableBindings(adTest)]]; 
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[_tableView]-0-|" 
                     options:0 
                     metrics:nil 
                     views:NSDictionaryOfVariableBindings(_tableView)]]; 
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[profilHeader]-0-[adTest]-0-[_tableView]-0-|" 
                     options:0 
                     metrics:nil 
                     views:NSDictionaryOfVariableBindings(profilHeader, adTest, _tableView)]]; 

그러나 물론 그것은 ... 작동하지 않습니다와 나는 내가이 얻을 시간의 몇 디버깅 다시 시작하면, 왜 말할 수 아니에요 디버거의 의견 블록 :

2013-02-22 00:17:13.207 MyApplication[6822:907] 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) 
(
    "<NSLayoutConstraint:0x1d0b20d0 H:[UIView:0x1d0ae7e0]-(0)-| (Names: '|':UIView:0x1c596de0)>", 
    "<NSLayoutConstraint:0x1d0b2090 H:|-(0)-[UIView:0x1d0ae7e0] (Names: '|':UIView:0x1c596de0)>", 
    "<NSLayoutConstraint:0x1d0b2000 H:[PMMainProfilHeader:0x1d09f5b0]-(0)-| (Names: '|':UIView:0x1c596de0)>", 
    "<NSLayoutConstraint:0x1d0b2320 H:|-(0)-[PMMainProfilHeader:0x1d09f5b0] (Names: '|':UIView:0x1c596de0)>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5dcb10 h=--& v=--& UIView:0x1d0ae7e0.midX ==>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5daf80 h=--& v=--& PMMainProfilHeader:0x1d09f5b0.midX == + 160>" 
) 

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x1d0b20d0 H:[UIView:0x1d0ae7e0]-(0)-| (Names: '|':UIView:0x1c596de0)> 

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-02-22 00:17:41.706 MyApplication[6822:907] 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) 
(
    "<NSLayoutConstraint:0x1c5ab460 V:[PMMainProfilHeader:0x1d09f5b0]-(0)-[UIView:0x1d0ae7e0]>", 
    "<NSLayoutConstraint:0x1c5ab3f0 V:|-(0)-[PMMainProfilHeader:0x1d09f5b0] (Names: '|':UIView:0x1c596de0)>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5dcca0 h=--& v=--& UIView:0x1d0ae7e0.midY ==>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5db050 h=--& v=--& PMMainProfilHeader:0x1d09f5b0.midY == + 50>" 
) 

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x1c5ab460 V:[PMMainProfilHeader:0x1d09f5b0]-(0)-[UIView:0x1d0ae7e0]> 

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-02-22 00:17:43.382 MyApplication[6822:907] 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:0x1d0c0530 h=--& v=--& UITableView:0x1db44600.midX ==>", 
    "<NSLayoutConstraint:0x1c5ab160 H:[UITableView:0x1db44600]-(0)-| (Names: '|':UIView:0x1c596de0)>", 
    "<NSLayoutConstraint:0x1c5ab120 H:|-(0)-[UITableView:0x1db44600] (Names: '|':UIView:0x1c596de0)>", 
    "<NSLayoutConstraint:0x1d0b2000 H:[PMMainProfilHeader:0x1d09f5b0]-(0)-| (Names: '|':UIView:0x1c596de0)>", 
    "<NSLayoutConstraint:0x1d0b2320 H:|-(0)-[PMMainProfilHeader:0x1d09f5b0] (Names: '|':UIView:0x1c596de0)>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5daf80 h=--& v=--& PMMainProfilHeader:0x1d09f5b0.midX == + 160>" 
) 

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x1c5ab160 H:[UITableView:0x1db44600]-(0)-| (Names: '|':UIView:0x1c596de0)> 

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-02-22 00:17:45.290 MyApplication[6822:907] 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:0x1c5dcce0 h=--& v=--& V:[UIView:0x1d0ae7e0(0)]>", 
    "<NSLayoutConstraint:0x1c5ab510 V:[UITableView:0x1db44600]-(0)-| (Names: '|':UIView:0x1c596de0)>", 
    "<NSLayoutConstraint:0x1c5ab4b0 V:[UIView:0x1d0ae7e0]-(0)-[UITableView:0x1db44600]>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5ed510 h=-&- v=-&- UILayoutContainerView:0x1c5d1440.height == UIWindow:0x1c564480.height>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5ef2e0 h=--- v=--- V:[UIWindow:0x1c564480(480)]>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5eb9e0 h=-&- v=-&- UINavigationTransitionView:0x1c5d2b20.height == UILayoutContainerView:0x1c5d1440.height>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5e9f80 h=-&- v=-&- UIViewControllerWrapperView:0x1d0ba580.height == UINavigationTransitionView:0x1c5d2b20.height>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5e8610 h=-&- v=-&- UILayoutContainerView:0x1d096c30.height == UIViewControllerWrapperView:0x1d0ba580.height>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5e6ed0 h=-&- v=-&- UITransitionView:0x1d0999d0.height == UILayoutContainerView:0x1d096c30.height - 49>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5e5980 h=-&- v=-&- UIViewControllerWrapperView:0x1c5cb7a0.height == UITransitionView:0x1d0999d0.height - 20>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1d0c0710 h=--& v=--& UITableView:0x1db44600.midY ==>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5e4270 h=-&- v=-&- UIView:0x1c596de0.height == UIViewControllerWrapperView:0x1c5cb7a0.height>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5dcca0 h=--& v=--& UIView:0x1d0ae7e0.midY ==>" 
) 

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x1c5ab4b0 V:[UIView:0x1d0ae7e0]-(0)-[UITableView:0x1db44600]> 

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-02-22 00:17:48.283 MyApplication[6822:907] 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) 
(
    "<NSLayoutConstraint:0x1c5ab510 V:[UITableView:0x1db44600]-(0)-| (Names: '|':UIView:0x1c596de0)>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5ed510 h=-&- v=-&- UILayoutContainerView:0x1c5d1440.height == UIWindow:0x1c564480.height>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5ef2e0 h=--- v=--- V:[UIWindow:0x1c564480(480)]>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5eb9e0 h=-&- v=-&- UINavigationTransitionView:0x1c5d2b20.height == UILayoutContainerView:0x1c5d1440.height>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5e9f80 h=-&- v=-&- UIViewControllerWrapperView:0x1d0ba580.height == UINavigationTransitionView:0x1c5d2b20.height>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5e8610 h=-&- v=-&- UILayoutContainerView:0x1d096c30.height == UIViewControllerWrapperView:0x1d0ba580.height>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5e6ed0 h=-&- v=-&- UITransitionView:0x1d0999d0.height == UILayoutContainerView:0x1d096c30.height - 49>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5e5980 h=-&- v=-&- UIViewControllerWrapperView:0x1c5cb7a0.height == UITransitionView:0x1d0999d0.height - 20>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1d0c0710 h=--& v=--& UITableView:0x1db44600.midY ==>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1c5e4270 h=-&- v=-&- UIView:0x1c596de0.height == UIViewControllerWrapperView:0x1c5cb7a0.height>", 
    "<NSAutoresizingMaskLayoutConstraint:0x1d0c0750 h=--& v=--& V:[UITableView:0x1db44600(0)]>" 
) 

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x1c5ab510 V:[UITableView:0x1db44600]-(0)-| (Names: '|':UIView:0x1c596de0)> 

전체 (거대한) 게시물을 읽어 주셔서 감사합니다 !! 누군가가 왜 작동하지 않는지 알기를 바랍니다!

+0

'Xcode에서 제약에 대해 이야기하는 이상한 오류를 얻는 것'의 복제본이 가능합니다 (http://stackoverflow.com/questions/11664115/getting-weird-error-talking-about-constraints-in-xcode) –

답변

10

좋아, 나는

난 그냥와 제약 조건을 사용하고 각보기에 대한 setTranslatesAutoresizingMaskIntoConstraints 전화를했다 대답을 ... 발견 ...

[profilHeader setTranslatesAutoresizingMaskIntoConstraints:NO]; 
[adTest setTranslatesAutoresizingMaskIntoConstraints:NO]; 
[_tableView setTranslatesAutoresizingMaskIntoConstraints:NO]; 

가 누군가를 도움이되기를 바랍니다

+0

나는 이것을 할 수 없습니다. 모든 코드가 Interface Bui에서 수행하는 것보다 효율적이었습니다. 알았어. 설정하는 것이 더 쉽고, 발생하는 상황에 대한 시각적 피드백을 얻을 수 있으며, 충돌이있는 경우 UI에서 잘못되거나 잘못된 경고 나 오류가있는 것을 볼 수 있습니다. 또한이 작업을 수행하여 translatesAutoresizingMaskIntoConstraints를 막을 수 있습니다. –

관련 문제