2014-10-27 117 views
0

我想通過繼承來輕鬆定製Mvvmcross對話框實現中的某些元素。更改MvvmCross對話框元素的佈局/框架

顏色和字體設置得很好,但如果我嘗試設置文本標籤框(在本示例中爲100 X ......),我無法使其保持粘貼狀態。

任何人都可以指出我在哪裏出錯的方向嗎?在幾個不同的地方嘗試過。

public class MyBooleanElement : BooleanElement { 

    public MyBooleanElement (string caption) : base(caption, false) 
    { 

    } 

    protected override UISwitch CreateSwitch() 
    { 
     UISwitch s = base.CreateSwitch(); 
     s.BackgroundColor = UIColor.Clear; 
     s.Opaque = false; 
     s.Layer.Opacity = 0.25f; 
     return s; 
    } 

    protected override UITableViewCell GetCellImpl(UITableView tv) 
    { 
     var cell = base.GetCellImpl(tv); 

     if (cell.BackgroundColor != UIColor.Clear) { 
      cell.BackgroundColor = UIColor.Clear; 
      cell.TextLabel.Font = Theme.GetContentFont(); 
      cell.TextLabel.TextColor = UIColor.White; 

      cell.TextLabel.Frame = new RectangleF(100, 0, 320, 20); // this is not holding, resets to 15 
      cell.ContentView.Frame = new RectangleF(50, cell.ContentView.Frame.Top, cell.ContentView.Frame.Width, cell.ContentView.Frame.Height); // try this also? 
     } 

     return cell; 
    } 

    protected override void UpdateCaptionDisplay(UITableViewCell cell) 
    { 
     base.UpdateCaptionDisplay(cell); 

     if (cell != null) { 
      cell.TextLabel.Frame = new RectangleF(100, 0, 320, 20); // this is not holding, resets to 15 
      cell.TextLabel.BackgroundColor = UIColor.Blue;   // Yet this works? some constraints somewhere cannot see in source! 
     } 
    } 
} 

回答

0

框架的對話框部分爲您定位標題(標籤)和控件。

你應該看一下源代碼,也許試着理解它是如何工作的。

您可以在調試時從一個斷點開始並進入源代碼。我相信你會看到15值的設置。

對不起,我不能給你一個確切的答案。我自己也遇到了一些與iPad上的對話框元素不正確定位有關的問題,我不得不挖掘一下。

+0

謝謝安德烈,我對源代碼有很好的看法,並且必須按照您的說法設置下一步的調試,因爲您可能會猜到希望以前有人碰到過。您是否使用PC上的Visual Studio進行調試或XS? – WickedW 2014-10-27 18:42:04