2016-01-24 47 views
0

我正在使用C#和Xamarin製作基本的筆記記錄應用程序。 我遇到的問題是在我的AddNoteViewController中,佈局的順序錯誤。 正確的佈局應該是:Xamarin Studio iOS應用程序中的屏幕布局不正常

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

回答

1

titleEntryBox和descriptionLabel器兩者都位於10100

相關問題