c# - Xamarin Studio 中 iOS 应用程序的屏幕布局乱序

标签 c# ios xamarin.ios xamarin-studio

我正在使用 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);
        }
    }
}

enter image description here

最佳答案

titleEntryBox 和 descriptionLabel 都定位在 10,100

关于c# - Xamarin Studio 中 iOS 应用程序的屏幕布局乱序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34976121/

相关文章:

ios - 制作一个允许用户从不同站点下载视频的应用程序

c# - NavigationController 颜色和左键

c# - 在 linq foreach 中调用方法 - 有多少开销?

c# - 使用 C# 选择、复制和重新插入一系列 Excel 行

c# - 为什么 Entity Framework 将名为 "People"的表映射为我的 .edmx 文件中名为 "Person"的实体

iphone - ShareKit加密应用提交

ios - 无法使用 JSON 类型的参数列表调用类型 'Int' 的初始值设定项

ios - 添加观察者时 AVPlayer 崩溃

c# - 通过 URL 加载图像在 Xamarin Forms 中不起作用

c# - 在一个数组中找到一个接口(interface)的具体实现,并移动到数组的顶部