0
好吧,我看到了其他问题,他们建议使用FluentLayouts,但我想这样做没有它只使用约束。 所以问题是这样的: 我创建了这个应用程序的导航栏和tabBar,现在我试图插入一个MyViewController
2按钮,其中一个在中间(我张贴的代码)和右下导航条。Xamarin和自动布局没有界面生成器
//------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));
}
有了这个代码,因为它定位在(0,0),我不知道为什么,有人可以给我一个提示Button1的没有出现呢?另一个问题是我不知道如何获得导航栏的底部值,所以我可以把button2放在那里。我跟着this文章。
是啊,我创立了关于AutoresizingMask给出,但问题是,有没有按钮都与此同时,与EdgesForExtendedLayout = UIRectEdge.None;所有的问题都解决了。谢谢 – DQuaglio 2014-12-01 09:40:20