2014-11-25 5 views
0

나는 FluentLayouts를 사용하도록 제안한 다른 질문을 보았습니다.하지만 제약 조건 만 사용하면이 작업을 수행하고 싶습니다. 그래서 문제는 이것입니다 : 나는 navigationbar와 tabBar로이 앱을 만들었습니다. 이제는 MyViewController 버튼 2 개를 삽입하려고합니다. 그 중 하나는 중간에 있습니다 (내가 게시 한 코드) 그리고 오른쪽 아래에 네비게이션 바. 위치가 (0,0) 내가 왜이 사람이 나에게 힌트를 줄 수 있다는 것을 알고하지 않기 때문에 button1을 전혀 표시되지 않는이 코드 Xamarin과 Autolayout없이 인터페이스 빌더

//------Appdelegate.cs 
    myViewController = new MyViewController(); 
    UINavigationController myNavController = new UINavigationController (myViewController); 
    window.RootViewController = myNavController; 
//-----MyViewController 
public override void ViewDidLoad() 
     { 
      base.ViewDidLoad(); 
      button1.SetTitle("Button1", UIControlState.Normal); 
      button1.BackgroundColor = UIColor.Red; 
      button2.SetTitle("Button2", UIControlState.Normal); 
      button2.BackgroundColor = UIColor.Gray; 
      View.AddSubview (button1); 
      View.AddSubview (button2); 
      View.AddConstraint (NSLayoutConstraint.Create (button1, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, View,NSLayoutAttribute.CenterX, 1, 0)); 
      View.AddConstraint (NSLayoutConstraint.Create (button1, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, View,NSLayoutAttribute.CenterY, 1, 0)); 
} 

? 그리고 다른 문제는 내가 navigationbar의 bottow 값을 얻는 방법을 모르겠다. 그래서 button2를 넣을 수있다. 나는 this 기사를 따라 갔다. 그렇지 않으면 autoresizingmask 덮어 씁니다,
button1.TranslatesAutoresizingMaskIntoConstraints = false; 
button2.TranslatesAutoresizingMaskIntoConstraints = false; 

그래서 당신은 당신의 제약 조건을 사용할 수 있습니다

답변

0

은 당신이 뭔가를 할 것이다. 또한 당신은 내가 당신의 버튼의 잘못된 위치가 그래 내가 AutoresizingMask 대해 설립

+0

이 마지막 라인 제공하고 있다고 생각

EdgesForExtendedLayout = UIRectEdge.None; 

를 사용하지 말아야하지만 문제는 전혀 단추가 없다고했다 그걸로, EdgesForExtendedLayout = UIRectEdge.None; 모든 문제가 해결 .. 감사 – DQuaglio