我正在使用 C#
和 Xamarin 制作基本的笔记应用程序。
我遇到的问题是,在我的 AddNoteViewController
中,布局顺序错误。
正确的布局应该是:
1. Title entry box
2. Description label for text input
3. Text input field
但是,尽管我在代码中指定了布局,但描述标签不知何故位于顶部,标题输入框上方。
AddNoteViewController_.cs
using System;
using UIKit;
namespace NoteTaker.iOS
{
public class AddNoteViewController : UIViewController
{
public AddNoteViewController ()
{
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
this.NavigationController.NavigationBar.BarTintColor = UIColor.FromRGB (255, 0, 255);
this.Title = "New Note";
this.NavigationController.NavigationBar.TitleTextAttributes = new UIStringAttributes () { ForegroundColor = UIColor.White };
this.NavigationController.NavigationBar.TintColor = UIColor.White;
this.View.BackgroundColor = UIColor.White;
var titleEntryBox = new UITextField () {
Frame = new CoreGraphics.CGRect (10, 100, 250, 100),
BackgroundColor = UIColor.Clear,
Placeholder = "Enter title...",
TextColor = UIColor.Black
};
var descriptionLabel = new UILabel () {
Frame = new CoreGraphics.CGRect (10, 100, 250, 35),
Text = "Enter description below"
};
var descriptionEntryBox = new UITextView () {
Frame = new CoreGraphics.CGRect (10, 220, 250, 100),
BackgroundColor = UIColor.Clear,
TextColor = UIColor.Black
};
this.View.Add (titleEntryBox);
this.View.Add (descriptionLabel);
this.View.Add (descriptionEntryBox);
}
}
}
最佳答案
titleEntryBox 和 descriptionLabel 都定位在 10,100
关于c# - Xamarin Studio 中 iOS 应用程序的屏幕布局乱序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34976121/